Bug 1134841 - Hold ServiceWorker alive during install event's waitUntil(). r=bz, a=lizzard
☠☠ backed out by 95a6f19afe8a ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 01 May 2015 08:14:42 -0700
changeset 267330 19b46672d2368e50b35b443e9c19b7803f8d3a5d
parent 267329 c67ad1e64f00fed48d6c5151b5cd1f0f194f9104
child 267331 a6edf943c3b7748423a4d67b91a3a0872ae66150
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lizzard
bugs1134841
milestone39.0a2
Bug 1134841 - Hold ServiceWorker alive during install event's waitUntil(). r=bz, a=lizzard
dom/workers/ServiceWorkerManager.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -1019,26 +1019,29 @@ ServiceWorkerManager::AppendPendingOpera
 
 /*
  * Used to handle ExtendableEvent::waitUntil() and proceed with
  * installation/activation.
  */
 class LifecycleEventPromiseHandler final : public PromiseNativeHandler
 {
   nsMainThreadPtrHandle<ContinueLifecycleTask> mTask;
+  nsMainThreadPtrHandle<ServiceWorker> mServiceWorker;
   bool mActivateImmediately;
 
   virtual
   ~LifecycleEventPromiseHandler()
   { }
 
 public:
   LifecycleEventPromiseHandler(const nsMainThreadPtrHandle<ContinueLifecycleTask>& aTask,
+                               const nsMainThreadPtrHandle<ServiceWorker>& aServiceWorker,
                                bool aActivateImmediately)
     : mTask(aTask)
+    , mServiceWorker(aServiceWorker)
     , mActivateImmediately(aActivateImmediately)
   {
     MOZ_ASSERT(!NS_IsMainThread());
   }
 
   void
   ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
   {
@@ -1125,17 +1128,17 @@ LifecycleEventWorkerRunnable::DispatchLi
   InstallEvent* installEvent = event->AsInstallEvent();
   if (installEvent) {
     activateImmediately = installEvent->ActivateImmediately();
     // FIXME(nsm): Set activeWorker to the correct thing.
     // FIXME(nsm): Install error handler for any listener errors.
   }
 
   nsRefPtr<LifecycleEventPromiseHandler> handler =
-    new LifecycleEventPromiseHandler(mTask, activateImmediately);
+    new LifecycleEventPromiseHandler(mTask, mServiceWorker, activateImmediately);
   waitUntilPromise->AppendNativeHandler(handler);
   return true;
 }
 
 void
 ServiceWorkerRegistrationInfo::TryToActivate()
 {
   if (!IsControllingDocuments()) {