зеркало из https://github.com/mozilla/pjs.git
Make nsIChannel implementations follow the rules that prevent them from leaking due to cycles with their notification callbacks. b=303043 r=biesi sr=darin
This commit is contained in:
Родитель
2cc6ed06f9
Коммит
4f125b95bb
|
@ -503,6 +503,11 @@ nsWyciwygChannel::OnStopRequest(nsIRequest *request, nsISupports *ctx, nsresult
|
|||
CloseCacheEntry(mStatus);
|
||||
mPump = 0;
|
||||
mIsPending = PR_FALSE;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,10 @@ nsLDAPChannel::Cancel(nsresult aStatus)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
mEventSink = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -890,6 +894,10 @@ nsLDAPChannel::OnLDAPSearchResult(nsILDAPMessage *aMessage)
|
|||
}
|
||||
}
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
mEventSink = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -532,6 +532,11 @@ GeckoProtocolChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult
|
|||
|
||||
mPump = 0;
|
||||
mContentStream = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -395,6 +395,11 @@ nsDateTimeChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult sta
|
|||
|
||||
mPump = 0;
|
||||
mTransport = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -417,6 +417,11 @@ nsFingerChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult statu
|
|||
|
||||
mPump = 0;
|
||||
mTransport = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -444,6 +444,10 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctx
|
|||
} // if we got an error code
|
||||
} // if we have a mailnews url.
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressEventSink = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -720,6 +720,11 @@ nsJARChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status)
|
|||
NS_IF_RELEASE(mJarInput);
|
||||
mIsPending = PR_FALSE;
|
||||
mDownloader = 0; // this may delete the underlying jar file
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -518,6 +518,10 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
|||
aListener->OnDataAvailable(this, ctxt, inputStr, 0, iconBuffer.Length());
|
||||
}
|
||||
aListener->OnStopRequest(this, ctxt, rv);
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -737,6 +737,9 @@ NS_IMETHODIMP nsIconChannel::OnStopRequest(nsIRequest* aRequest, nsISupports* aC
|
|||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -500,6 +500,9 @@ NS_IMETHODIMP nsIconChannel::OnStopRequest(nsIRequest* aRequest, nsISupports* aC
|
|||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,9 @@ interface nsIChannel : nsIRequest
|
|||
* channel may ignore changes to the notificationCallbacks attribute after
|
||||
* it has been opened. This rule also applies to notificationCallbacks
|
||||
* queried from the channel's loadgroup.
|
||||
*
|
||||
* When the channel is done, it must not continue holding references to
|
||||
* this object.
|
||||
*/
|
||||
attribute nsIInterfaceRequestor notificationCallbacks;
|
||||
|
||||
|
|
|
@ -375,6 +375,11 @@ nsInputStreamChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult
|
|||
|
||||
mPump = 0;
|
||||
mContentStream = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -479,6 +479,9 @@ nsDataChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|||
if (mLoadGroup)
|
||||
mLoadGroup->RemoveRequest(this, nsnull, status);
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -555,6 +555,11 @@ nsFileChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status)
|
|||
|
||||
mRequest = 0;
|
||||
mStream = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -610,6 +610,11 @@ nsFTPChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext,
|
|||
NS_RELEASE(mFTPState);
|
||||
}
|
||||
mIsPending = PR_FALSE;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mEventSink = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -547,6 +547,12 @@ nsGopherChannel::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
|||
mTransport->Close(mStatus);
|
||||
mTransport = 0;
|
||||
mPump = 0;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
mPrompter = 0;
|
||||
mProgressSink = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ nsresult nsExtProtocolChannel::SetURI(nsIURI* aURI)
|
|||
|
||||
nsresult nsExtProtocolChannel::OpenURL()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIExternalProtocolService> extProtService (do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
|
||||
|
||||
if (extProtService)
|
||||
|
@ -181,9 +182,13 @@ nsresult nsExtProtocolChannel::OpenURL()
|
|||
// get an nsIPrompt from the channel if we can
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, prompt);
|
||||
return extProtService->LoadURI(mUrl, prompt);
|
||||
rv = extProtService->LoadURI(mUrl, prompt);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Drop notification callbacks to prevent cycles.
|
||||
mCallbacks = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::Open(nsIInputStream **_retval)
|
||||
|
|
Загрузка…
Ссылка в новой задаче