Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
Consumer Class Reference
Inheritance diagram for Consumer:
Inheritance graph
[legend]
Collaboration diagram for Consumer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER 
Consumer ()
virtual ~Consumer ()
nsresult Init (nsIURI *aURI, nsIChannel *aChannel, nsISupports *aContext)
nsresult Validate (nsIRequest *request, nsISupports *aContext)
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.

Public Attributes

PRBool mOnStart
PRBool mOnStop
PRInt32 mOnDataCount
nsCOMPtr< nsIURImURI
nsCOMPtr< nsIChannelmChannel
nsCOMPtr< nsIEqualsmContext

Detailed Description

Definition at line 94 of file TestCallbacks.cpp.


Constructor & Destructor Documentation

Definition at line 183 of file TestCallbacks.cpp.

Consumer::~Consumer ( ) [virtual]

Definition at line 189 of file TestCallbacks.cpp.

                    {
    fprintf(stderr, "Consumer::~Consumer -> in\n\n");

    if (!mOnStart) {
        gError = PR_TRUE;
        fprintf(stderr, "ERROR: Never got an OnStart\n");
    }

    if (!mOnStop) {
        gError = PR_TRUE;
        fprintf(stderr, "ERROR: Never got an OnStop \n");
    }

    fprintf(stderr, "Consumer::~Consumer -> out\n\n");
    gKeepRunning--;
}

Here is the call graph for this function:


Member Function Documentation

nsresult Consumer::Init ( nsIURI aURI,
nsIChannel aChannel,
nsISupports *  aContext 
)

Definition at line 207 of file TestCallbacks.cpp.

                                                                        {
    mURI     = aURI;
    mChannel = aChannel;
    mContext = do_QueryInterface(aContext);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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:

nsresult Consumer::Validate ( nsIRequest request,
nsISupports *  aContext 
)

Definition at line 215 of file TestCallbacks.cpp.

                                                             {
    nsresult rv = NS_OK;
    nsCOMPtr<nsIURI> uri;
    nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);

    rv = aChannel->GetURI(getter_AddRefs(uri));
    if (NS_FAILED(rv)) return rv;

    PRBool same = PR_FALSE;

    rv = mURI->Equals(uri, &same);
    if (NS_FAILED(rv)) return rv;

    if (!same)
        fprintf(stderr, "INFO: URIs do not match\n");

    rv = mContext->Equals((void*)aContext, &same);
    if (NS_FAILED(rv)) return rv;

    if (!same) {
        gError = PR_TRUE;
        fprintf(stderr, "ERROR: Contexts do not match\n");
    }
    return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 110 of file TestCallbacks.cpp.

Definition at line 111 of file TestCallbacks.cpp.

Definition at line 108 of file TestCallbacks.cpp.

Definition at line 106 of file TestCallbacks.cpp.

Definition at line 107 of file TestCallbacks.cpp.

Definition at line 109 of file TestCallbacks.cpp.


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