Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | Protected Attributes
nsStreamLoader Class Reference

#include <nsStreamLoader.h>

Inheritance diagram for nsStreamLoader:
Inheritance graph
[legend]
Collaboration diagram for nsStreamLoader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLOADER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER 
nsStreamLoader ()
 ~nsStreamLoader ()
void init (in nsIChannel aChannel, in nsIStreamLoaderObserver aObserver, in nsISupports aContext)
 Initialize this stream loader, and start loading the data.
void onDataAvailable (in nsIRequest aRequest, in nsISupports aContext, in nsIInputStream aInputStream, in unsigned long aOffset, in unsigned long aCount)
 Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.

Static Public Member Functions

static NS_METHOD Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)

Public Attributes

readonly attribute unsigned long numBytesRead
 Gets the number of bytes read so far.
readonly attribute nsIRequest request
 Gets the request that loaded this file.

Static Protected Member Functions

static NS_METHOD WriteSegmentFun (nsIInputStream *, void *, const char *, PRUint32, PRUint32, PRUint32 *)

Protected Attributes

nsCOMPtr< nsIStreamLoaderObservermObserver
nsCOMPtr< nsISupports > mContext
nsCString mData
nsCOMPtr< nsIRequestmRequest

Detailed Description

Definition at line 46 of file nsStreamLoader.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSISTREAMLOADER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER nsStreamLoader::nsStreamLoader ( ) [inline]

Definition at line 55 of file nsStreamLoader.h.

{ }

Here is the caller graph for this function:

Definition at line 56 of file nsStreamLoader.h.

{}

Member Function Documentation

NS_METHOD nsStreamLoader::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 79 of file nsStreamLoader.cpp.

{
  if (aOuter) return NS_ERROR_NO_AGGREGATION;

  nsStreamLoader* it = new nsStreamLoader();
  if (it == nsnull)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(it);
  nsresult rv = it->QueryInterface(aIID, aResult);
  NS_RELEASE(it);
  return rv;
}

Here is the call graph for this function:

void nsIStreamLoader::init ( in nsIChannel  aChannel,
in nsIStreamLoaderObserver  aObserver,
in nsISupports  aContext 
) [inherited]

Initialize this stream loader, and start loading the data.

Parameters:
aChannelA Channel to load data from. This must not be asyncOpen'd yet!
aObserverAn observer that will be notified when the data is complete.
aContextMay be null. Will be passed to the observer.
Note:
Failure to open the channel will be indicated by an async callback to the observer.
void nsIStreamListener::onDataAvailable ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsIInputStream  aInputStream,
in unsigned long  aOffset,
in unsigned long  aCount 
) [inherited]

Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.

The onDataAvailable impl must read exactly |aCount| bytes of data before returning.

Parameters:
aRequestrequest corresponding to the source of the data
aContextuser defined context
aInputStreaminput stream containing the data chunk
aOffsetNumber of bytes that were sent in previous onDataAvailable calls for this request. In other words, the sum of all previous count parameters. If that number is greater than or equal to 2^32, this parameter will be PR_UINT32_MAX (2^32 - 1).
aCountnumber of bytes available in the stream

NOTE: The aInputStream parameter must implement readSegments.

An exception thrown from onDataAvailable has the side-effect of causing the request to be canceled.

void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

NS_METHOD nsStreamLoader::WriteSegmentFun ( nsIInputStream inStr,
void closure,
const char *  fromSegment,
PRUint32  toOffset,
PRUint32  count,
PRUint32 writeCount 
) [static, protected]

Definition at line 145 of file nsStreamLoader.cpp.

{
  nsStreamLoader *self = (nsStreamLoader *) closure;

  self->mData.Append(fromSegment, count);
  *writeCount = count;

  return NS_OK;
}

Member Data Documentation

nsCOMPtr<nsISupports> nsStreamLoader::mContext [protected]

Definition at line 66 of file nsStreamLoader.h.

Definition at line 67 of file nsStreamLoader.h.

Definition at line 65 of file nsStreamLoader.h.

Definition at line 68 of file nsStreamLoader.h.

readonly attribute unsigned long nsIStreamLoader::numBytesRead [inherited]

Gets the number of bytes read so far.

Definition at line 85 of file nsIStreamLoader.idl.

Gets the request that loaded this file.

null after the request has finished loading.

Definition at line 91 of file nsIStreamLoader.idl.


The documentation for this class was generated from the following files: