Back to index

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

#include <nsAsyncStreamListener.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
OnStartRequest (nsIRequest *request, nsISupports *context)
NS_IMETHOD OnStopRequest (nsIRequest *request, nsISupports *context, nsresult aStatus)
NS_IMETHOD OnDataAvailable (nsIRequest *request, nsISupports *context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength)
NS_IMETHOD Init (nsIStreamListener *aListener, nsIEventQueue *aEventQ)
 nsAsyncStreamListener ()
virtual ~nsAsyncStreamListener ()
NS_METHOD Init (nsIRequestObserver *, nsIEventQueue *)
nsISupports * GetReceiver ()
void Clear ()
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.
void init (in nsIStreamListener aReceiver, in nsIEventQueue aEventQ)
 Initializes an nsIAsyncStreamListener.
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.

Static Public Member Functions

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

Protected Attributes

nsCOMPtr< nsIEventQueuemEventQueue
nsCOMPtr< nsIRequestObservermReceiver

Detailed Description

Definition at line 78 of file nsAsyncStreamListener.h.


Constructor & Destructor Documentation

Definition at line 109 of file nsAsyncStreamListener.h.

Here is the caller graph for this function:

virtual nsAsyncStreamListener::~nsAsyncStreamListener ( ) [inline, virtual]

Member Function Documentation

void nsAsyncStreamObserver::Clear ( void  ) [inline, inherited]

Definition at line 69 of file nsAsyncStreamListener.h.

Here is the caller graph for this function:

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

Reimplemented from nsAsyncStreamObserver.

Definition at line 482 of file nsAsyncStreamListener.cpp.

{
    if (aOuter)
        return NS_ERROR_NO_AGGREGATION;
    nsAsyncStreamListener* l = new nsAsyncStreamListener();
    if (l == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(l);
    nsresult rv = l->QueryInterface(aIID, aResult);
    NS_RELEASE(l);
    return rv;
}

Here is the call graph for this function:

nsISupports* nsAsyncStreamObserver::GetReceiver ( ) [inline, inherited]

Definition at line 68 of file nsAsyncStreamListener.h.

{ return mReceiver.get(); }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsAsyncStreamObserver::Init ( nsIRequestObserver aObserver,
nsIEventQueue aEventQ 
) [inherited]

Definition at line 174 of file nsAsyncStreamListener.cpp.

{
    nsresult rv = NS_OK;
    NS_ASSERTION(aObserver, "null observer");
    mReceiver = aObserver;
        
    nsCOMPtr<nsIEventQueueService> eventQService = 
             do_GetService(kEventQueueService, &rv);
    if (NS_FAILED(rv)) 
    return rv;
        
    rv = eventQService->ResolveEventQueue(aEventQ, getter_AddRefs(mEventQueue));
    return rv;
}

Here is the call graph for this function:

void nsIAsyncStreamListener::init ( in nsIStreamListener  aReceiver,
in nsIEventQueue  aEventQ 
) [inherited]

Initializes an nsIAsyncStreamListener.

Parameters:
aReceiverreceives listener notifications on the other thread
aEventQmay be null indicating the calling thread's event queue
NS_IMETHOD nsAsyncStreamListener::Init ( nsIStreamListener aListener,
nsIEventQueue aEventQ 
) [inline]

Definition at line 104 of file nsAsyncStreamListener.h.

                                                                          {
        return nsAsyncStreamObserver::Init(aListener, aEventQ);
    }
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.

NS_IMETHODIMP nsAsyncStreamListener::OnDataAvailable ( nsIRequest request,
nsISupports *  context,
nsIInputStream aIStream,
PRUint32  aSourceOffset,
PRUint32  aLength 
)

Definition at line 434 of file nsAsyncStreamListener.cpp.

{
    nsresult rv;
    nsOnDataAvailableEvent* event = 
        new nsOnDataAvailableEvent(this, request, context);
    if (event == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;

    rv = event->Init(aIStream, aSourceOffset, aLength);
    if (NS_FAILED(rv)) goto failed;
#if defined(PR_LOGGING)
    PLEventQueue *equeue;
    mEventQueue->GetPLEventQueue(&equeue);
    if (!gStreamEventLog)
      gStreamEventLog = PR_NewLogModule("netlibStreamEvent");
    PR_LOG(gStreamEventLog, PR_LOG_DEBUG,
           ("nsAsyncStreamObserver: Data [this=%x queue=%x event=%x]",
            this, equeue, event));
#endif
    rv = event->Fire(mEventQueue);
    if (NS_FAILED(rv)) goto failed;
    return rv;

  failed:
    delete event;
    return rv;
}
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:

NS_DECL_ISUPPORTS_INHERITED NS_IMETHOD nsAsyncStreamListener::OnStartRequest ( nsIRequest request,
nsISupports *  context 
) [inline]

Definition at line 85 of file nsAsyncStreamListener.h.

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_IMETHOD nsAsyncStreamListener::OnStopRequest ( nsIRequest request,
nsISupports *  context,
nsresult  aStatus 
) [inline]

Definition at line 91 of file nsAsyncStreamListener.h.

    { 
        return nsAsyncStreamObserver::OnStopRequest(request, context, aStatus);
    }

Member Data Documentation

Definition at line 72 of file nsAsyncStreamListener.h.

Definition at line 73 of file nsAsyncStreamListener.h.


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