Bug 373701. Make sure to properly cancel multipart image loads when they need canceling. r=joedrew, sr=biesi
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 29 Sep 2008 16:46:53 -0400
changeset 19875 afcc5aa0fb07d0b22d1144cf258d4530405f985f
parent 19874 dd1c08d6d99380380880a513f96bc09fc242bf74
child 19876 6357eb31cec64741a90e209cb55af1159fb30f25
push id2512
push userbzbarsky@mozilla.com
push dateMon, 29 Sep 2008 20:46:59 +0000
treeherdermozilla-central@afcc5aa0fb07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoedrew, biesi
bugs373701
milestone1.9.1b1pre
Bug 373701. Make sure to properly cancel multipart image loads when they need canceling. r=joedrew, sr=biesi
modules/libpr0n/src/imgRequest.cpp
--- a/modules/libpr0n/src/imgRequest.cpp
+++ b/modules/libpr0n/src/imgRequest.cpp
@@ -604,16 +604,31 @@ NS_IMETHODIMP imgRequest::OnStartRequest
   LOG_SCOPE(gImgLog, "imgRequest::OnStartRequest");
 
   NS_ASSERTION(!mDecoder, "imgRequest::OnStartRequest -- we already have a decoder");
 
   nsCOMPtr<nsIMultiPartChannel> mpchan(do_QueryInterface(aRequest));
   if (mpchan)
       mIsMultiPartChannel = PR_TRUE;
 
+  /*
+   * If mRequest is null here, then we need to set it so that we'll be able to
+   * cancel it if our Cancel() method is called.  Note that this can only
+   * happen for multipart channels.  We could simply not null out mRequest for
+   * non-last parts, if GetIsLastPart() were reliable, but it's not.  See
+   * https://bugzilla.mozilla.org/show_bug.cgi?id=339610
+   */
+  if (!mRequest) {
+    NS_ASSERTION(mpchan,
+                 "We should have an mRequest here unless we're multipart");
+    nsCOMPtr<nsIChannel> chan;
+    mpchan->GetBaseChannel(getter_AddRefs(chan));
+    mRequest = chan;
+  }
+
   /* set our state variables to their initial values, but advance mState
      to onStartRequest. */
   mImageStatus = imgIRequest::STATUS_NONE;
   mState = onStartRequest;
 
   nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
   if (channel)
     channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));