Bug 918880 - Gracefully recover from scheduleUpdate() failure. r=fabrice, a=koi+
authorHonza Bambas <honzab.moz@firemni.cz>
Sun, 22 Dec 2013 18:31:15 -0800
changeset 175469 47c95516b5bba1ea80ad7450d8e0fb262f0a9cb8
parent 175468 32876e74afaedfd590da8f457534466717308b88
child 175470 be03830fb191820e99e054f6cafb48d8e96338cf
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, koi
bugs918880
milestone28.0a2
Bug 918880 - Gracefully recover from scheduleUpdate() failure. r=fabrice, a=koi+
dom/ipc/TabParent.cpp
uriloader/prefetch/OfflineCacheUpdateParent.cpp
uriloader/prefetch/OfflineCacheUpdateParent.h
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1554,18 +1554,22 @@ TabParent::AllocPOfflineCacheUpdateParen
                                           const URIParams& aDocumentURI,
                                           const bool& stickDocument)
 {
   nsRefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
     new mozilla::docshell::OfflineCacheUpdateParent(OwnOrContainingAppId(),
                                                     IsBrowserElement());
 
   nsresult rv = update->Schedule(aManifestURI, aDocumentURI, stickDocument);
-  if (NS_FAILED(rv))
-    return nullptr;
+  if (NS_FAILED(rv)) {
+    // Must dispatch since the parent is not at this moment ready yet.
+    nsRefPtr<nsRunnableMethod<mozilla::docshell::OfflineCacheUpdateParent> > event =
+      NS_NewRunnableMethod(update, &mozilla::docshell::OfflineCacheUpdateParent::Kill);
+    NS_DispatchToCurrentThread(event);
+  }
 
   POfflineCacheUpdateParent* result = update.get();
   update.forget();
   return result;
 }
 
 bool
 TabParent::DeallocPOfflineCacheUpdateParent(mozilla::docshell::POfflineCacheUpdateParent* actor)
--- a/uriloader/prefetch/OfflineCacheUpdateParent.cpp
+++ b/uriloader/prefetch/OfflineCacheUpdateParent.cpp
@@ -136,16 +136,22 @@ OfflineCacheUpdateParent::Schedule(const
         nsCOMPtr<nsIURI> stickURI;
         documentURI->Clone(getter_AddRefs(stickURI));
         update->StickDocument(stickURI);
     }
 
     return NS_OK;
 }
 
+void
+OfflineCacheUpdateParent::Kill()
+{
+    unused << SendFinish(false, false);
+}
+
 NS_IMETHODIMP
 OfflineCacheUpdateParent::UpdateStateChanged(nsIOfflineCacheUpdate *aUpdate, uint32_t state)
 {
     if (mIPCClosed)
         return NS_ERROR_UNEXPECTED;
 
     LOG(("OfflineCacheUpdateParent::StateEvent [%p]", this));
 
--- a/uriloader/prefetch/OfflineCacheUpdateParent.h
+++ b/uriloader/prefetch/OfflineCacheUpdateParent.h
@@ -35,16 +35,18 @@ public:
     NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
     NS_DECL_NSILOADCONTEXT
 
     nsresult
     Schedule(const URIParams& manifestURI,
              const URIParams& documentURI,
              const bool& stickDocument);
 
+    void Kill();
+
     OfflineCacheUpdateParent(uint32_t aAppId, bool aIsInBrowser);
     ~OfflineCacheUpdateParent();
 
     virtual void ActorDestroy(ActorDestroyReason why);
 
 private:
     void RefcountHitZero();
     bool mIPCClosed;