Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS Listener ()
virtual ~Listener ()
NS_IMETHOD OnStartRequest (nsIRequest *request, nsISupports *ctxt)
NS_IMETHOD OnStopRequest (nsIRequest *request, nsISupports *ctxt, nsresult aStatus)
NS_IMETHOD OnDataAvailable (nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
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.

Detailed Description

Definition at line 139 of file TestRes.cpp.


Constructor & Destructor Documentation

Definition at line 144 of file TestRes.cpp.

{}
virtual Listener::~Listener ( ) [inline, virtual]

Definition at line 145 of file TestRes.cpp.

{}

Member Function Documentation

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_IMETHOD Listener::OnDataAvailable ( nsIRequest request,
nsISupports *  ctxt,
nsIInputStream inStr,
PRUint32  sourceOffset,
PRUint32  count 
) [inline]

Definition at line 183 of file TestRes.cpp.

                                                                      {
        nsresult rv;
        char buf[1024];
        while (count > 0) {
            PRUint32 amt;
            rv = inStr->Read(buf, sizeof(buf), &amt);
            count -= amt;
            char* c = buf;
            while (amt-- > 0) {
                fputc(*c++, stdout);
            }
        }
        return NS_OK;
    }

Here is the call graph for this function:

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_IMETHOD Listener::OnStartRequest ( nsIRequest request,
nsISupports *  ctxt 
) [inline]

Definition at line 147 of file TestRes.cpp.

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

        rv = channel->GetURI(getter_AddRefs(uri));
        if (NS_SUCCEEDED(rv)) {
            char* str;
            rv = uri->GetSpec(&str);
            if (NS_SUCCEEDED(rv)) {
                fprintf(stdout, "Starting to load %s\n", str);
                nsCRT::free(str);
            }
        }
        return NS_OK;
    }

Here is the call 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_IMETHOD Listener::OnStopRequest ( nsIRequest request,
nsISupports *  ctxt,
nsresult  aStatus 
) [inline]

Definition at line 164 of file TestRes.cpp.

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

        rv = channel->GetURI(getter_AddRefs(uri));
        if (NS_SUCCEEDED(rv)) {
            char* str;
            rv = uri->GetSpec(&str);
            if (NS_SUCCEEDED(rv)) {
                fprintf(stdout, "Ending load %s, status=%x\n", str, aStatus);
                nsCRT::free(str);
            }
        }
        gDone = PR_TRUE;
        return NS_OK;
    }

Here is the call graph for this function:


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