Bug 918864. r=bz

This commit is contained in:
Olli Pettay 2013-10-17 13:59:55 -04:00
parent ae06dc3af5
commit 7e45225636

View File

@ -132,6 +132,7 @@ public:
: mService(aService)
, mManifestURI(aManifestURI)
, mDocumentURI(aDocumentURI)
, mDidReleaseThis(false)
{
mDocument = do_GetWeakReference(aDocument);
}
@ -141,6 +142,7 @@ private:
nsCOMPtr<nsIURI> mManifestURI;
nsCOMPtr<nsIURI> mDocumentURI;
nsCOMPtr<nsIWeakReference> mDocument;
bool mDidReleaseThis;
};
NS_IMPL_ISUPPORTS2(nsOfflineCachePendingUpdate,
@ -169,11 +171,16 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
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;
}
@ -209,9 +216,14 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
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;