Back to index

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

#include <nsUnicharStreamLoader.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIUNICHARSTREAMLOADER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER 
nsUnicharStreamLoader ()
virtual ~nsUnicharStreamLoader ()
void init (in nsIChannel aChannel, in nsIUnicharStreamLoaderObserver aObserver, in nsISupports aContext, in unsigned long aSegmentSize)
 Initializes the unichar stream loader.
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

const unsigned long DEFAULT_SEGMENT_SIZE = 4096
readonly attribute nsIChannel channel
 The channel attribute is only valid inside the onDetermineCharset and onStreamComplete callbacks.
readonly attribute ACString charset
 The charset that onDetermineCharset returned, if that's been called.

Static Protected Member Functions

static NS_METHOD WriteSegmentFun (nsIInputStream *, void *, const char *, PRUint32, PRUint32, PRUint32 *)
 callback method used for ReadSegments

Protected Attributes

nsCOMPtr
< nsIUnicharStreamLoaderObserver
mObserver
nsCOMPtr< nsISupports > mContext
nsCString mCharset
nsCOMPtr< nsIChannelmChannel
nsCOMPtr< nsIInputStreammInputStream
nsCOMPtr< nsIOutputStreammOutputStream
PRUint32 mSegmentSize

Detailed Description

Definition at line 50 of file nsUnicharStreamLoader.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSIUNICHARSTREAMLOADER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER nsUnicharStreamLoader::nsUnicharStreamLoader ( ) [inline]

Definition at line 59 of file nsUnicharStreamLoader.h.

{ }

Here is the caller graph for this function:

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

Definition at line 60 of file nsUnicharStreamLoader.h.

{};

Member Function Documentation

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

Definition at line 102 of file nsUnicharStreamLoader.cpp.

{
  if (aOuter) return NS_ERROR_NO_AGGREGATION;

  nsUnicharStreamLoader* it = new nsUnicharStreamLoader();
  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 nsIUnicharStreamLoader::init ( in nsIChannel  aChannel,
in nsIUnicharStreamLoaderObserver  aObserver,
in nsISupports  aContext,
in unsigned long  aSegmentSize 
) [inherited]

Initializes the unichar stream loader.

Parameters:
aChannelthe channel to read data from. This should not be opened; the loader will open the channel itself.
aObserverthe observer to notify when a charset is needed and when the load is complete
aContextan opaque context pointer
aSegmentSizethe size of the segments to use for the data, in bytes
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 nsUnicharStreamLoader::WriteSegmentFun ( nsIInputStream aInputStream,
void aClosure,
const char *  aSegment,
PRUint32  aToOffset,
PRUint32  aCount,
PRUint32 aWriteCount 
) [static, protected]

callback method used for ReadSegments

Definition at line 214 of file nsUnicharStreamLoader.cpp.

{
  nsUnicharStreamLoader *self = (nsUnicharStreamLoader *) aClosure;
  if (self->mCharset.IsEmpty()) {
    // First time through.  Call our observer.
    NS_ASSERTION(self->mObserver, "This should never be possible");

    nsresult rv = self->mObserver->OnDetermineCharset(self,
                                                      self->mContext,
                                                      aSegment,
                                                      aCount,
                                                      self->mCharset);
    
    if (NS_FAILED(rv) || self->mCharset.IsEmpty()) {
      // The observer told us nothing useful
      self->mCharset.AssignLiteral("ISO-8859-1");
    }

    NS_ASSERTION(IsASCII(self->mCharset),
                 "Why is the charset name non-ascii?  Whose bright idea was that?");
  }
  // Don't consume any data
  *aWriteCount = 0;
  return NS_BASE_STREAM_WOULD_BLOCK;
}

Here is the call graph for this function:


Member Data Documentation

The channel attribute is only valid inside the onDetermineCharset and onStreamComplete callbacks.

Otherwise it will be null.

Definition at line 103 of file nsIUnicharStreamLoader.idl.

readonly attribute ACString nsIUnicharStreamLoader::charset [inherited]

The charset that onDetermineCharset returned, if that's been called.

Definition at line 109 of file nsIUnicharStreamLoader.idl.

Definition at line 81 of file nsIUnicharStreamLoader.idl.

Definition at line 75 of file nsUnicharStreamLoader.h.

Definition at line 74 of file nsUnicharStreamLoader.h.

nsCOMPtr<nsISupports> nsUnicharStreamLoader::mContext [protected]

Definition at line 73 of file nsUnicharStreamLoader.h.

Definition at line 76 of file nsUnicharStreamLoader.h.

Definition at line 72 of file nsUnicharStreamLoader.h.

Definition at line 77 of file nsUnicharStreamLoader.h.

Definition at line 78 of file nsUnicharStreamLoader.h.


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