diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index 1579a4bb286..f799cf69163 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -1605,13 +1605,23 @@ nsHttpChannel::Cancel(nsresult status) NS_IMETHODIMP nsHttpChannel::Suspend() { - return NS_ERROR_NOT_IMPLEMENTED; + LOG(("nsHttpChannel::Suspend [this=%x]\n", this)); + if (mTransaction) + mTransaction->Suspend(); + else if (mCacheReadRequest) + mCacheReadRequest->Suspend(); + return NS_OK; } NS_IMETHODIMP nsHttpChannel::Resume() { - return NS_ERROR_NOT_IMPLEMENTED; + LOG(("nsHttpChannel::Resume [this=%x]\n", this)); + if (mTransaction) + mTransaction->Resume(); + else if (mCacheReadRequest) + mCacheReadRequest->Resume(); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp b/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp index 6ae9af0cadc..9ed79d18df3 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpConnection.cpp @@ -225,14 +225,40 @@ nsHttpConnection::OnTransactionComplete(nsHttpTransaction *trans, nsresult statu return NS_OK; } +// not called from the socket thread +nsresult +nsHttpConnection::Suspend() +{ + // we only bother to suspend the read request, since that's the only + // one that will effect our consumers. + + nsCOMPtr readReq; + { + nsAutoLock lock(mLock); + readReq = mReadRequest; + } + + if (readReq) + readReq->Suspend(); + + return NS_OK; +} + // not called from the socket thread nsresult nsHttpConnection::Resume() { - // XXX may require a lock to ensure thread safety + // we only need to worry about resuming the read request, since that's + // the only one that can be suspended. - if (mReadRequest) - mReadRequest->Resume(); + nsCOMPtr readReq; + { + nsAutoLock lock(mLock); + readReq = mReadRequest; + } + + if (readReq) + readReq->Resume(); return NS_OK; } diff --git a/mozilla/netwerk/protocol/http/src/nsHttpConnection.h b/mozilla/netwerk/protocol/http/src/nsHttpConnection.h index 35e6183ee11..9bad9c719e3 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpConnection.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpConnection.h @@ -76,7 +76,8 @@ public: // called by the transaction to inform the connection that it is done. nsresult OnTransactionComplete(nsHttpTransaction *, nsresult status); - // called by the transaction to resume a read-in-progress + // called by the transaction to suspend/resume a read-in-progress + nsresult Suspend(); nsresult Resume(); // called to cause the underlying socket to start speaking SSL diff --git a/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp b/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp index e168831b5ff..50e92d64a74 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp @@ -636,7 +636,10 @@ nsHttpTransaction::Cancel(nsresult status) NS_IMETHODIMP nsHttpTransaction::Suspend() { - return NS_ERROR_NOT_IMPLEMENTED; + LOG(("nsHttpTransaction::Suspend [this=%x]\n", this)); + if (mConnection && !mTransactionDone) + mConnection->Suspend(); + return NS_OK; } // called from the consumer thread, while nothing is happening on the socket thread. @@ -644,7 +647,7 @@ NS_IMETHODIMP nsHttpTransaction::Resume() { LOG(("nsHttpTransaction::Resume [this=%x]\n", this)); - if (mConnection) + if (mConnection && !mTransactionDone) mConnection->Resume(); return NS_OK; }