Back to index

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

List of all members.

Public Member Functions

 StreamToFile (FILE *fp)
NS_DECL_ISUPPORTS NS_IMETHOD GetBindInfo (nsIURI *aURL)
NS_IMETHOD OnProgress (nsIURI *aURL, PRInt32 Progress, PRInt32 ProgressMax)
NS_IMETHOD OnStatus (nsIURI *aURL, const nsString &aMsg)
NS_IMETHOD OnStartRequest (nsIRequest *aRequest, nsISupports *)
NS_IMETHOD OnDataAvailable (nsIRequest *aRequest, nsISupports *, nsIInputStream *pIStream, PRUint32 aOffset, PRUint32 aCount)
NS_IMETHOD OnStopRequest (nsIRequest *aRequest, nsISupports *, PRUint32 status)
PRBool IsDone () const
PRBool HaveError () const
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.

Protected Member Functions

virtual ~StreamToFile ()

Protected Attributes

PRBool mDone
PRBool mError
FILEmFile

Detailed Description

Definition at line 72 of file grabpage.cpp.


Constructor & Destructor Documentation

Definition at line 96 of file grabpage.cpp.

StreamToFile::~StreamToFile ( ) [protected, virtual]

Definition at line 105 of file grabpage.cpp.

{
  if (nsnull != mFile) {
    fclose(mFile);
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 113 of file grabpage.cpp.

{
  return 0;
}
PRBool StreamToFile::HaveError ( ) const [inline]

Definition at line 86 of file grabpage.cpp.

{ return mError; }

Here is the caller graph for this function:

PRBool StreamToFile::IsDone ( ) const [inline]

Definition at line 85 of file grabpage.cpp.

{ return mDone; }

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.

NS_IMETHODIMP StreamToFile::OnDataAvailable ( nsIRequest aRequest,
nsISupports *  ,
nsIInputStream pIStream,
PRUint32  aOffset,
PRUint32  aCount 
)

Definition at line 137 of file grabpage.cpp.

{
  PRUint32 len;
  do {
    char buffer[4000];
    nsresult err = pIStream->Read(buffer, sizeof(buffer), &len);
    if (NS_SUCCEEDED(err)) {
      if (nsnull != mFile) {
        fwrite(buffer, 1, len, mFile);
      }
    }
  } while (len > 0);
  return 0;
}

Here is the call graph for this function:

NS_IMETHODIMP StreamToFile::OnProgress ( nsIURI aURL,
PRInt32  Progress,
PRInt32  ProgressMax 
)

Definition at line 119 of file grabpage.cpp.

{
  return 0;
}
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_IMETHODIMP StreamToFile::OnStartRequest ( nsIRequest aRequest,
nsISupports *  aSomething 
)

Definition at line 131 of file grabpage.cpp.

{
  return 0;
}

Definition at line 125 of file grabpage.cpp.

{
  return 0;
}
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_IMETHODIMP StreamToFile::OnStopRequest ( nsIRequest aRequest,
nsISupports *  aSomething,
PRUint32  status 
)

Definition at line 159 of file grabpage.cpp.

{
  mDone = PR_TRUE;
  if (0 != status) {
    mError = PR_TRUE;
  }
  return 0;
}

Member Data Documentation

Definition at line 91 of file grabpage.cpp.

Definition at line 92 of file grabpage.cpp.

FILE* StreamToFile::mFile [protected]

Definition at line 93 of file grabpage.cpp.


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