Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsIncrementalDownload.cpp File Reference
#include "nsIIncrementalDownload.h"
#include "nsIRequestObserver.h"
#include "nsIProgressEventSink.h"
#include "nsIChannelEventSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIObserverService.h"
#include "nsIObserver.h"
#include "nsIPropertyBag2.h"
#include "nsIServiceManager.h"
#include "nsILocalFile.h"
#include "nsITimer.h"
#include "nsInt64.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsWeakReference.h"
#include "nsChannelProperties.h"
#include "prio.h"
#include "prprf.h"

Go to the source code of this file.

Classes

class  nsIncrementalDownload

Defines

#define NS_ERROR_DOWNLOAD_COMPLETE   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 1)
#define NS_ERROR_DOWNLOAD_NOT_PARTIAL   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 2)
#define DEFAULT_CHUNK_SIZE   (4096 * 16)
#define DEFAULT_INTERVAL   60
#define MAX_RETRY_COUNT   20

Functions

static nsresult WriteToFile (nsILocalFile *lf, const char *data, PRUint32 len, PRInt32 flags)
static nsresult AppendToFile (nsILocalFile *lf, const char *data, PRUint32 len)
static void MakeRangeSpec (const nsInt64 &size, const nsInt64 &maxSize, PRInt32 chunkSize, PRBool fetchRemaining, nsCString &rangeSpec)
 NS_IMPL_ISUPPORTS8 (nsIncrementalDownload, nsIIncrementalDownload, nsIRequest, nsIStreamListener, nsIRequestObserver, nsIObserver, nsIInterfaceRequestor, nsIChannelEventSink, nsISupportsWeakReference) NS_IMETHODIMP nsIncrementalDownload
NS_METHOD net_NewIncrementalDownload (nsISupports *outer, const nsIID &iid, void **result)

Define Documentation

#define DEFAULT_CHUNK_SIZE   (4096 * 16)

Definition at line 69 of file nsIncrementalDownload.cpp.

Definition at line 70 of file nsIncrementalDownload.cpp.

Definition at line 73 of file nsIncrementalDownload.cpp.

Definition at line 60 of file nsIncrementalDownload.cpp.

Definition at line 65 of file nsIncrementalDownload.cpp.


Function Documentation

static nsresult AppendToFile ( nsILocalFile lf,
const char *  data,
PRUint32  len 
) [static]

Definition at line 93 of file nsIncrementalDownload.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void MakeRangeSpec ( const nsInt64 size,
const nsInt64 maxSize,
PRInt32  chunkSize,
PRBool  fetchRemaining,
nsCString rangeSpec 
) [static]

Definition at line 101 of file nsIncrementalDownload.cpp.

{
  rangeSpec.AssignLiteral("bytes=");
  rangeSpec.AppendInt(PRInt64(size));
  rangeSpec.Append('-');

  if (fetchRemaining)
    return;

  nsInt64 end = size + nsInt64(chunkSize);
  if (maxSize != nsInt64(-1) && end > maxSize)
    end = maxSize;
  end -= 1;

  rangeSpec.AppendInt(PRInt64(end));
}

Here is the caller graph for this function:

NS_METHOD net_NewIncrementalDownload ( nsISupports *  outer,
const nsIID iid,
void **  result 
)

Definition at line 797 of file nsIncrementalDownload.cpp.

{
  if (outer)
    return NS_ERROR_NO_AGGREGATION;

  nsIncrementalDownload *d = new nsIncrementalDownload();
  if (!d)
    return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(d);
  nsresult rv = d->QueryInterface(iid, result);
  NS_RELEASE(d);
  return rv;
}

Here is the call graph for this function:

Definition at line 322 of file nsIncrementalDownload.cpp.

{
  NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_INITIALIZED);

  return mURI->GetSpec(name);
}
static nsresult WriteToFile ( nsILocalFile lf,
const char *  data,
PRUint32  len,
PRInt32  flags 
) [static]

Definition at line 78 of file nsIncrementalDownload.cpp.

{
  PRFileDesc *fd;
  nsresult rv = lf->OpenNSPRFileDesc(flags, 0600, &fd);
  if (NS_FAILED(rv))
    return rv;

  if (len)
    rv = PR_Write(fd, data, len) == PRInt32(len) ? NS_OK : NS_ERROR_FAILURE;

  PR_Close(fd);
  return rv;
}

Here is the caller graph for this function: