Bug 1290116 P2 Clean up ServiceWorkerManager::StopControllingADocument(). r=asuth
☠☠ backed out by 35b2715748a3 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 05 Aug 2016 02:08:20 -0700
changeset 397507 74ceee4dc2f4872e16b6de01e46575008094fc5a
parent 397506 90006dffbe5bde43ced588089cace5218251ef9d
child 397508 ca998a8cbe48339adb024aaea67daef3795d041b
push id25332
push usermaglione.k@gmail.com
push dateSat, 06 Aug 2016 21:21:51 +0000
reviewersasuth
bugs1290116
milestone51.0a1
Bug 1290116 P2 Clean up ServiceWorkerManager::StopControllingADocument(). r=asuth
dom/workers/ServiceWorkerManager.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -1996,27 +1996,30 @@ ServiceWorkerManager::StartControllingAD
   }
   Telemetry::Accumulate(Telemetry::SERVICE_WORKER_CONTROLLED_DOCUMENTS, 1);
 }
 
 void
 ServiceWorkerManager::StopControllingADocument(ServiceWorkerRegistrationInfo* aRegistration)
 {
   aRegistration->StopControllingADocument();
-  if (!aRegistration->IsControllingDocuments()) {
-    if (aRegistration->mPendingUninstall) {
-      RemoveRegistration(aRegistration);
-    } else {
-      // We use to aggressively terminate the worker at this point, but it
-      // caused problems.  There are more uses for a service worker than actively
-      // controlled documents.  We need to let the worker naturally terminate
-      // in case its handling push events, message events, etc.
-      aRegistration->TryToActivateAsync();
-    }
+  if (aRegistration->IsControllingDocuments()) {
+    return;
   }
+
+  if (aRegistration->mPendingUninstall) {
+    RemoveRegistration(aRegistration);
+    return;
+  }
+
+  // We use to aggressively terminate the worker at this point, but it
+  // caused problems.  There are more uses for a service worker than actively
+  // controlled documents.  We need to let the worker naturally terminate
+  // in case its handling push events, message events, etc.
+  aRegistration->TryToActivateAsync();
 }
 
 NS_IMETHODIMP
 ServiceWorkerManager::GetScopeForUrl(nsIPrincipal* aPrincipal,
                                      const nsAString& aUrl, nsAString& aScope)
 {
   MOZ_ASSERT(aPrincipal);