Bug 595785. Make sure the right channel is always passed to download progress listeners' onStateChange methods. r=sdwilsh,bzbarsky

This commit is contained in:
Grigory Mozhaev 2011-03-23 10:45:21 -04:00
Родитель 79b392b950
Коммит 7eab4a1fd3
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -1243,6 +1243,7 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
, mContentLength(-1)
, mProgress(0)
, mDataBuffer(nsnull)
, mKeepRequestAlive(PR_FALSE)
, mRequest(nsnull)
{
@ -1744,6 +1745,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
// do this first! make sure we don't try to take an action until the user tells us what they want to do
// with it...
mReceivedDispositionInfo = PR_FALSE;
mKeepRequestAlive = PR_TRUE;
// invoke the dialog!!!!! use mWindowContext as the window context parameter for the dialog request
mDialog = do_CreateInstance( NS_HELPERAPPLAUNCHERDLG_CONTRACTID, &rv );
@ -1994,7 +1996,10 @@ NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISuppor
nsresult aStatus)
{
mStopRequestIssued = PR_TRUE;
mRequest = nsnull;
if (!mKeepRequestAlive)
mRequest = nsnull;
// Cancel if the request did not complete successfully.
if (!mCanceled && NS_FAILED(aStatus))
{
@ -2135,6 +2140,8 @@ nsresult nsExternalAppHandler::CreateProgressListener()
// OnStopRequest.
SetWebProgressListener(tr);
mRequest = nsnull;
return rv;
}
@ -2468,6 +2475,9 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel(nsresult aReason)
// Break our reference cycle with the helper app dialog (set up in
// OnStartRequest)
mDialog = nsnull;
mRequest = nsnull;
// shutdown our stream to the temp file
if (mOutStream)
{

Просмотреть файл

@ -437,6 +437,12 @@ protected:
nsCOMPtr<nsIChannel> mOriginalChannel; /**< in the case of a redirect, this will be the pre-redirect channel. */
nsCOMPtr<nsIHelperAppLauncherDialog> mDialog;
/**
* Keep request alive in case when helper non-modal dialog shown.
* Thus in OnStopRequest the mRequest will not be set to null (it will be set to null further).
*/
PRBool mKeepRequestAlive;
/**
* The request that's being loaded. Not used after OnStopRequest, so a weak
* reference suffices. Initialized in OnStartRequest.