restoring nsBaseChannel changes. reverting nsInputStreamPump changes.

This commit is contained in:
darin%meer.net 2006-03-03 18:39:40 +00:00
Родитель 5a87292dc0
Коммит 8330866f4e
2 изменённых файлов: 13 добавлений и 30 удалений

Просмотреть файл

@ -575,7 +575,7 @@ nsBaseChannel::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
mPump->PeekStream(CallTypeSniffers, NS_STATIC_CAST(nsIChannel*, this));
}
// TODO(darin): SUSPEND_PUMP_FOR_SCOPE();
SUSPEND_PUMP_FOR_SCOPE();
return mListener->OnStartRequest(this, mListenerContext);
}
@ -617,7 +617,7 @@ nsBaseChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
nsIInputStream *stream, PRUint32 offset,
PRUint32 count)
{
// TODO(darin): SUSPEND_PUMP_FOR_SCOPE();
SUSPEND_PUMP_FOR_SCOPE();
nsresult rv = mListener->OnDataAvailable(this, mListenerContext, stream,
offset, count);

Просмотреть файл

@ -57,17 +57,6 @@ static PRLogModuleInfo *gStreamPumpLog = nsnull;
#endif
#define LOG(args) PR_LOG(gStreamPumpLog, PR_LOG_DEBUG, args)
//-----------------------------------------------------------------------------
static NS_METHOD
GetBytesAvailable(nsIInputStream *stream, void *closure, const char *segment,
PRUint32 offset, PRUint32 count, PRUint32 *result)
{
PRUint32 *avail = NS_STATIC_CAST(PRUint32 *, closure);
*avail = count;
return NS_ERROR_ABORT; // return from ReadSegments call
}
//-----------------------------------------------------------------------------
// nsInputStreamPump methods
//-----------------------------------------------------------------------------
@ -362,11 +351,11 @@ nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream *stream)
// this function has been called from a PLEvent, so we can safely call
// any listener or progress sink methods directly from here.
mWaiting = PR_FALSE;
for (;;) {
if (mSuspendCount || mState == STATE_IDLE)
if (mSuspendCount || mState == STATE_IDLE) {
mWaiting = PR_FALSE;
break;
}
PRUint32 nextState;
switch (mState) {
@ -385,6 +374,7 @@ nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream *stream)
NS_ASSERTION(mState == STATE_TRANSFER, "unexpected state");
NS_ASSERTION(NS_SUCCEEDED(mStatus), "unexpected status");
mWaiting = PR_FALSE;
mStatus = EnsureWaiting();
if (NS_SUCCEEDED(mStatus))
break;
@ -520,20 +510,13 @@ nsInputStreamPump::OnStateTransfer()
if (NS_SUCCEEDED(mStatus)) {
if (NS_FAILED(rv))
mStatus = rv;
else {
// Check to see if stream will have more data. If so, then stay in
// the STATE_TRANSFER state. Otherwise, advance to STATE_STOP.
//
// NOTE: Calling Available is insufficient since that method could
// return 0 bytes available and NS_OK when it is at end-of-
// file but not closed. We would not be able to distinguish
// that case from a stream that is merely waiting for more
// data to become available. By using ReadSegments we can
// tell if the stream will ever have more data.
//
PRUint32 n;
rv = mAsyncStream->ReadSegments(GetBytesAvailable, &avail, 1, &n);
if (rv == NS_BASE_STREAM_WOULD_BLOCK || (NS_SUCCEEDED(rv) && avail))
else if (avail) {
// if stream is now closed, advance to STATE_STOP right away.
// Available may return 0 bytes available at the moment; that
// would not mean that we are done.
// XXX async streams should have a GetStatus method!
rv = mAsyncStream->Available(&avail);
if (NS_SUCCEEDED(rv))
return STATE_TRANSFER;
}
}