mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1136969 - Add a check that OnStartRequest is called just once during the lifetime of a channel. r=mcmanus
This commit is contained in:
parent
c4456e9497
commit
570137e623
@ -82,6 +82,7 @@ HttpBaseChannel::HttpBaseChannel()
|
||||
, mForcePending(false)
|
||||
, mCorsIncludeCredentials(false)
|
||||
, mCorsMode(nsIHttpChannelInternal::CORS_MODE_NO_CORS)
|
||||
, mOnStartRequestCalled(false)
|
||||
{
|
||||
LOG(("Creating HttpBaseChannel @%x\n", this));
|
||||
|
||||
@ -2053,8 +2054,13 @@ void
|
||||
HttpBaseChannel::DoNotifyListener()
|
||||
{
|
||||
if (mListener) {
|
||||
MOZ_ASSERT(!mOnStartRequestCalled,
|
||||
"We should not call OnStartRequest twice");
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener = mListener;
|
||||
listener->OnStartRequest(this, mListenerContext);
|
||||
|
||||
mOnStartRequestCalled = true;
|
||||
}
|
||||
|
||||
// Make sure mIsPending is set to false. At this moment we are done from
|
||||
|
@ -424,6 +424,10 @@ protected:
|
||||
|
||||
bool mCorsIncludeCredentials;
|
||||
uint32_t mCorsMode;
|
||||
|
||||
// This parameter is used to ensure that we do not call OnStartRequest more
|
||||
// than once.
|
||||
bool mOnStartRequestCalled;
|
||||
};
|
||||
|
||||
// Share some code while working around C++'s absurd inability to handle casting
|
||||
|
@ -934,7 +934,10 @@ nsHttpChannel::CallOnStartRequest()
|
||||
|
||||
LOG((" calling mListener->OnStartRequest\n"));
|
||||
if (mListener) {
|
||||
MOZ_ASSERT(!mOnStartRequestCalled,
|
||||
"We should not call OsStartRequest twice");
|
||||
rv = mListener->OnStartRequest(this, mListenerContext);
|
||||
mOnStartRequestCalled = true;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
} else {
|
||||
@ -5519,7 +5522,10 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
|
||||
// NOTE: since we have a failure status, we can ignore the return
|
||||
// value from onStartRequest.
|
||||
if (mListener) {
|
||||
MOZ_ASSERT(!mOnStartRequestCalled,
|
||||
"We should not call OnStartRequest twice.");
|
||||
mListener->OnStartRequest(this, mListenerContext);
|
||||
mOnStartRequestCalled = true;
|
||||
} else {
|
||||
NS_WARNING("OnStartRequest skipped because of null listener");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user