adding some additional documentation per bzbarsky, b=192284

This commit is contained in:
darin%meer.net 2003-10-08 04:37:38 +00:00
parent 2b14b6a01c
commit 9e05fad4b2
3 changed files with 18 additions and 3 deletions

View File

@ -40,9 +40,12 @@
interface nsISyncStreamListener : nsIStreamListener
{
/**
* Returns an input stream that when read will fetch data delivered
* to the sync stream listener. The nsIInputStream implementation
* will wait for OnDataAvailable events before returning from Read.
* Returns an input stream that when read will fetch data delivered to the
* sync stream listener. The nsIInputStream implementation will wait for
* OnDataAvailable events before returning from Read.
*
* NOTE: Reading from the returned nsIInputStream may spin the current
* thread's event queue, which could result in any event being processed.
*/
readonly attribute nsIInputStream inputStream;
};

View File

@ -468,6 +468,9 @@ NS_NewSyncStreamListener(nsIStreamListener **aResult,
/**
* Implement the nsIChannel::Open(nsIInputStream**) method using the channel's
* AsyncOpen method.
*
* NOTE: Reading from the returned nsIInputStream may spin the current
* thread's event queue, which could result in any event being processed.
*/
inline nsresult
NS_ImplementChannelOpen(nsIChannel *aChannel,

View File

@ -116,9 +116,18 @@ nsSyncStreamListener::OnDataAvailable(nsIRequest *request,
PRUint32 bytesWritten;
nsresult rv = mPipeOut->WriteFrom(stream, count, &bytesWritten);
// if we get an error, then return failure. this will cause the
// channel to be canceled, and as a result our OnStopRequest method
// will be called immediately. because of this we do not need to
// set mStatus or mKeepWaiting here.
if (NS_FAILED(rv))
return rv;
// we expect that all data will be written to the pipe because
// the pipe was created to have "infinite" room.
NS_ASSERTION(bytesWritten == count, "did not write all data");
mKeepWaiting = PR_FALSE; // unblock Read
return NS_OK;
}