Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS MRJInputStream (MRJSession *session)
NS_IMETHOD OnStartBinding (nsIPluginStreamInfo *pluginInfo)
NS_IMETHOD OnDataAvailable (nsIPluginStreamInfo *pluginInfo, nsIInputStream *input, PRUint32 length)
NS_IMETHOD OnFileAvailable (nsIPluginStreamInfo *pluginInfo, const char *fileName)
NS_IMETHOD OnStopBinding (nsIPluginStreamInfo *pluginInfo, nsresult status)
NS_IMETHOD GetStreamType (nsPluginStreamType *result)
OSStatus read (void *buffer, SInt32 bufferSize, SInt32 *bytesRead)
void onStartBinding (in nsIPluginStreamInfo aPluginInfo)
 Notify the observer that the URL has started to load.
void onDataAvailable (in nsIPluginStreamInfo aPluginInfo, in nsIInputStream aInputStream, in unsigned long aLength)
 Notify the client that data is available in the input stream.
void onFileAvailable (in nsIPluginStreamInfo aPluginInfo, in string aFileName)
 Notify the client that data is available in the file.
void onStopBinding (in nsIPluginStreamInfo aPluginInfo, in nsresult aStatus)
 Notify the observer that the URL has finished loading.

Public Attributes

readonly attribute
nsPluginStreamType 
streamType
 Gets the type of the stream.

Private Types

typedef std::vector< char > buffer_t

Private Attributes

MRJMonitor mMonitor
buffer_t mBuffer
size_t mOffset
bool mComplete

Detailed Description

Definition at line 78 of file MRJNetworking.cpp.


Member Typedef Documentation

typedef std::vector<char> MRJInputStream::buffer_t [private]

Definition at line 80 of file MRJNetworking.cpp.


Constructor & Destructor Documentation

Definition at line 87 of file MRJNetworking.cpp.

        :   mMonitor(session), mOffset(0), mComplete(false)
    {
        mBuffer.reserve(8192);
    }

Member Function Documentation

Definition at line 119 of file MRJNetworking.cpp.

void nsIPluginStreamListener::onDataAvailable ( in nsIPluginStreamInfo  aPluginInfo,
in nsIInputStream  aInputStream,
in unsigned long  aLength 
) [inherited]

Notify the client that data is available in the input stream.

This method is called whenver data is written into the input stream by the networking library...

Parameters:
aPluginInfo- plugin stream info
aInputStream- the input stream containing the data. This stream can be either a blocking or non-blocking stream.
aLength- the amount of data that was just pushed into the stream.
Returns:
- the return value is currently ignored.

Definition at line 130 of file MRJNetworking.cpp.

{
    size_t oldSize = mBuffer.size();
    mBuffer.resize(oldSize + length);
    buffer_t::iterator buffer = mBuffer.begin() + oldSize;
    input->Read(buffer, length, &length);
    mMonitor.notify();
    return NS_OK;
}
void nsIPluginStreamListener::onFileAvailable ( in nsIPluginStreamInfo  aPluginInfo,
in string  aFileName 
) [inherited]

Notify the client that data is available in the file.

Parameters:
aPluginInfo- plugin stream info
aFileName- the name of the file containing the data
Returns:
- the return value is currently ignored.
NS_IMETHOD MRJInputStream::OnFileAvailable ( nsIPluginStreamInfo pluginInfo,
const char *  fileName 
) [inline]

Definition at line 103 of file MRJNetworking.cpp.

    {
        return NS_OK;
    }

Notify the observer that the URL has started to load.

This method is called only once, at the beginning of a URL load.

Parameters:
aPluginInfo- plugin stream info
Returns:
- the return value is currently ignored, in the future it may be used to cancel the URL load..

Definition at line 94 of file MRJNetworking.cpp.

    {
        return NS_OK;
    }
NS_IMETHOD MRJInputStream::OnStopBinding ( nsIPluginStreamInfo pluginInfo,
nsresult  status 
) [inline]

Definition at line 109 of file MRJNetworking.cpp.

    {
        if (!mComplete) {
            mComplete = true;
            mMonitor.notify();
        }
        return NS_OK;
    }

Here is the call graph for this function:

void nsIPluginStreamListener::onStopBinding ( in nsIPluginStreamInfo  aPluginInfo,
in nsresult  aStatus 
) [inherited]

Notify the observer that the URL has finished loading.

This method is called once when the networking library has finished processing the URL transaction initiatied via the nsINetService::Open(...) call.

This method is called regardless of whether the URL loaded successfully.

Parameters:
aPluginInfo- plugin stream info
aStatus- reason why the stream has been terminated
Returns:
- the return value is currently ignored.
OSStatus MRJInputStream::read ( void buffer,
SInt32  bufferSize,
SInt32 *  bytesRead 
)

Definition at line 140 of file MRJNetworking.cpp.

{
    size_t sz = mBuffer.size();
    while (mOffset >= sz && !mComplete) {
        // wait until there is some data to read.
        mMonitor.wait();
        sz = mBuffer.size();
    }
    
    SInt32 available = (sz - mOffset);
    if (bufferSize > available)
        bufferSize = available;

    if (bufferSize <= 0 && mComplete) {
        *bytesRead = 0;
        return noErr;
    }

    ::BlockMoveData(mBuffer.begin() + mOffset, buffer, bufferSize);
    *bytesRead = bufferSize;
    mOffset += bufferSize;
    
    return noErr;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 81 of file MRJNetworking.cpp.

Definition at line 83 of file MRJNetworking.cpp.

Definition at line 79 of file MRJNetworking.cpp.

size_t MRJInputStream::mOffset [private]

Definition at line 82 of file MRJNetworking.cpp.

Gets the type of the stream.

Parameters:
aStreamType- the type of the stream

Definition at line 118 of file nsIPluginStreamListener.idl.


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