Bug 918864. r=bz
authorOlli Pettay <bugs@pettay.fi>
Thu, 17 Oct 2013 13:59:55 -0400
changeset 164960 e0daf4f7c6659949ad084189d37252fc4e392aec
parent 164959 ac848ab26ba860b13dd37920b5ebc31c9a511d3c
child 164961 899981761c7dbdaeb65e590fec729241ec0e5721
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs918864
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 918864. r=bz
uriloader/prefetch/nsOfflineCacheUpdateService.cpp
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -127,25 +127,27 @@ public:
 
     nsOfflineCachePendingUpdate(nsOfflineCacheUpdateService *aService,
                                 nsIURI *aManifestURI,
                                 nsIURI *aDocumentURI,
                                 nsIDOMDocument *aDocument)
         : mService(aService)
         , mManifestURI(aManifestURI)
         , mDocumentURI(aDocumentURI)
+        , mDidReleaseThis(false)
         {
             mDocument = do_GetWeakReference(aDocument);
         }
 
 private:
     nsRefPtr<nsOfflineCacheUpdateService> mService;
     nsCOMPtr<nsIURI> mManifestURI;
     nsCOMPtr<nsIURI> mDocumentURI;
     nsCOMPtr<nsIWeakReference> mDocument;
+    bool mDidReleaseThis;
 };
 
 NS_IMPL_ISUPPORTS2(nsOfflineCachePendingUpdate,
                    nsIWebProgressListener,
                    nsISupportsWeakReference)
 
 //-----------------------------------------------------------------------------
 // nsOfflineCacheUpdateService::nsIWebProgressListener
@@ -164,21 +166,26 @@ nsOfflineCachePendingUpdate::OnProgressC
 }
 
 NS_IMETHODIMP
 nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
                                            nsIRequest *aRequest,
                                            uint32_t progressStateFlags,
                                            nsresult aStatus)
 {
+    if (mDidReleaseThis) {
+        return NS_OK;
+    }
     nsCOMPtr<nsIDOMDocument> updateDoc = do_QueryReferent(mDocument);
     if (!updateDoc) {
         // The document that scheduled this update has gone away,
         // we don't need to listen anymore.
         aWebProgress->RemoveProgressListener(this);
+        MOZ_ASSERT(!mDidReleaseThis);
+        mDidReleaseThis = true;
         NS_RELEASE_THIS();
         return NS_OK;
     }
 
     if (!(progressStateFlags & STATE_STOP)) {
         return NS_OK;
     }
 
@@ -204,19 +211,24 @@ nsOfflineCachePendingUpdate::OnStateChan
         bool isInBrowserElement;
         nsresult rv = GetAppIDAndInBrowserFromWindow(window, &appId, &isInBrowserElement);
         NS_ENSURE_SUCCESS(rv, rv);
 
         nsCOMPtr<nsIOfflineCacheUpdate> update;
         mService->Schedule(mManifestURI, mDocumentURI,
                            updateDoc, window, nullptr,
                            appId, isInBrowserElement, getter_AddRefs(update));
+        if (mDidReleaseThis) {
+            return NS_OK;
+        }
     }
 
     aWebProgress->RemoveProgressListener(this);
+    MOZ_ASSERT(!mDidReleaseThis);
+    mDidReleaseThis = true;
     NS_RELEASE_THIS();
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsOfflineCachePendingUpdate::OnLocationChange(nsIWebProgress* aWebProgress,
                                               nsIRequest* aRequest,