Make nsIChannel implementations follow the rules that prevent them from leaking due to cycles with their notification callbacks. b=303043 r=biesi sr=darin

git-svn-id: svn://10.0.0.236/trunk@177663 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%dbaron.org
2005-08-12 22:53:22 +00:00
parent d168cc9570
commit f5fb8ddaff
17 changed files with 81 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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)