mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Cancelling the loadgroup after we've run JS but before we've started pumping
data should still work. Bug 389151, r+sr=biesi
This commit is contained in:
parent
9ae7c9de67
commit
6b99198f47
@ -522,7 +522,12 @@ nsJSChannel::IsPending(PRBool *aResult)
|
||||
NS_IMETHODIMP
|
||||
nsJSChannel::GetStatus(nsresult *aResult)
|
||||
{
|
||||
if (NS_SUCCEEDED(mStatus) && mOpenedStreamChannel) {
|
||||
return mStreamChannel->GetStatus(aResult);
|
||||
}
|
||||
|
||||
*aResult = mStatus;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -623,7 +628,12 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
if (loadGroup) {
|
||||
loadGroup->AddRequest(this, nsnull);
|
||||
nsresult rv = loadGroup->AddRequest(this, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsActive = PR_FALSE;
|
||||
CleanupStrongRefs();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
mDocumentOnloadBlockedOn =
|
||||
@ -784,6 +794,19 @@ nsJSChannel::EvaluateScript()
|
||||
// mStreamChannel will call OnStartRequest and OnStopRequest on
|
||||
// us, so we'll be sure to call them on our listener.
|
||||
mOpenedStreamChannel = PR_TRUE;
|
||||
|
||||
// Now readd ourselves to the loadgroup so we can receive
|
||||
// cancellation notifications.
|
||||
mIsActive = PR_TRUE;
|
||||
if (loadGroup) {
|
||||
mStatus = loadGroup->AddRequest(this, nsnull);
|
||||
|
||||
// If AddRequest failed, that's OK. The key is to make sure we get
|
||||
// cancelled if needed, and that call just canceled us if it
|
||||
// failed. We'll still get notified by the stream channel when it
|
||||
// finishes.
|
||||
}
|
||||
|
||||
} else if (mIsAsync) {
|
||||
NotifyListener();
|
||||
}
|
||||
@ -951,8 +974,23 @@ nsJSChannel::OnStopRequest(nsIRequest* aRequest,
|
||||
nsCOMPtr<nsIStreamListener> listener = mListener;
|
||||
|
||||
CleanupStrongRefs();
|
||||
|
||||
// Make sure aStatus matches what GetStatus() returns
|
||||
if (NS_FAILED(mStatus)) {
|
||||
aStatus = mStatus;
|
||||
}
|
||||
|
||||
return listener->OnStopRequest(this, aContext, aStatus);
|
||||
nsresult rv = listener->OnStopRequest(this, aContext, aStatus);
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mStreamChannel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
if (loadGroup) {
|
||||
loadGroup->RemoveRequest(this, nsnull, mStatus);
|
||||
}
|
||||
|
||||
mIsActive = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user