Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsMsgProtocolStreamProvider ()
virtual ~nsMsgProtocolStreamProvider ()
void Init (nsMsgAsyncWriteProtocol *aProtInstance, nsIInputStream *aInputStream)
NS_IMETHODIMP OnOutputStreamReady (nsIAsyncOutputStream *aOutStream)
void onOutputStreamReady (in nsIAsyncOutputStream aStream)
 Called to indicate that the stream is either writable or closed.

Protected Attributes

nsMsgAsyncWriteProtocol * mMsgProtocol
nsCOMPtr< nsIInputStreammInStream

Detailed Description

Definition at line 1047 of file nsMsgProtocol.cpp.

Constructor & Destructor Documentation

Definition at line 1052 of file nsMsgProtocol.cpp.

{ }

Definition at line 1053 of file nsMsgProtocol.cpp.


Member Function Documentation

void nsMsgProtocolStreamProvider::Init ( nsMsgAsyncWriteProtocol *  aProtInstance,
nsIInputStream aInputStream 
) [inline]

Definition at line 1055 of file nsMsgProtocol.cpp.

      mMsgProtocol = aProtInstance;
      mInStream = aInputStream;

Called to indicate that the stream is either writable or closed.

aStreamThe stream whose asyncWait method was called.

Definition at line 1064 of file nsMsgProtocol.cpp.

        NS_ASSERTION(mInStream, "not initialized");

        nsresult rv;
        PRUint32 avail;

        // Write whatever is available in the pipe. If the pipe is empty, then
        // return NS_BASE_STREAM_WOULD_BLOCK; we will resume the write when there
        // is more data.

        rv = mInStream->Available(&avail);
        if (NS_FAILED(rv)) return rv;

        if (avail == 0) 
          // ok, stop writing...
          mMsgProtocol->mSuspendedWrite = PR_TRUE;
          return NS_OK;

        PRUint32 bytesWritten;
        rv =  aOutStream->WriteFrom(mInStream, PR_MIN(avail, 4096), &bytesWritten);
        // if were full at the time, the input stream may be backed up and we need to read any remains from the last ODA call
        // before we'll get more ODA calls
        if (mMsgProtocol->mSuspendedRead)


        // try to write again...
        if (NS_SUCCEEDED(rv))
          rv = aOutStream->AsyncWait(this, 0, 0, mMsgProtocol->mProviderEventQ);

        NS_ASSERTION(NS_SUCCEEDED(rv) || rv == NS_BINDING_ABORTED, "unexpected error writing stream");
        return NS_OK;

Member Data Documentation

Definition at line 1105 of file nsMsgProtocol.cpp.

nsMsgAsyncWriteProtocol* nsMsgProtocolStreamProvider::mMsgProtocol [protected]

Definition at line 1104 of file nsMsgProtocol.cpp.

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