Bug 1550059 - Clear ServiceWorker(Registration)Infos on shutdown. r=asuth a=jcristau
authorPerry Jiang <perry@mozilla.com>
Tue, 28 May 2019 21:14:44 +0000
changeset 536691 d9d324c0221e87da4e0ea032a63a7d7131422ae2
parent 536690 f474ee2548c62464668be3a1aad874dd8dc23c77
child 536692 9bce7f0a4e570404999d4c9d630b949d1047ddfc
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, jcristau
bugs1550059
milestone68.0
Bug 1550059 - Clear ServiceWorker(Registration)Infos on shutdown. r=asuth a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D30716
dom/serviceworkers/ServiceWorkerManager.cpp
dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
--- a/dom/serviceworkers/ServiceWorkerManager.cpp
+++ b/dom/serviceworkers/ServiceWorkerManager.cpp
@@ -439,16 +439,22 @@ void ServiceWorkerManager::MaybeStartShu
     it1.UserData()->mUpdateTimers.Clear();
 
     for (auto it2 = it1.UserData()->mJobQueues.Iter(); !it2.Done();
          it2.Next()) {
       RefPtr<ServiceWorkerJobQueue> queue = it2.UserData();
       queue->CancelAll();
     }
     it1.UserData()->mJobQueues.Clear();
+
+    for (auto it2 = it1.UserData()->mInfos.Iter(); !it2.Done(); it2.Next()) {
+      RefPtr<ServiceWorkerRegistrationInfo> regInfo = it2.UserData();
+      regInfo->Clear();
+    }
+    it1.UserData()->mInfos.Clear();
   }
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
 
     if (XRE_IsParentProcess()) {
       obs->RemoveObserver(this, CLEAR_ORIGIN_DATA);
--- a/dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
@@ -39,20 +39,27 @@ class ContinueActivateRunnable final : p
 
 }  // anonymous namespace
 
 void ServiceWorkerRegistrationInfo::Clear() {
   if (mEvaluatingWorker) {
     mEvaluatingWorker = nullptr;
   }
 
+  RefPtr<ServiceWorkerInfo> evaluating = mEvaluatingWorker.forget();
   RefPtr<ServiceWorkerInfo> installing = mInstallingWorker.forget();
   RefPtr<ServiceWorkerInfo> waiting = mWaitingWorker.forget();
   RefPtr<ServiceWorkerInfo> active = mActiveWorker.forget();
 
+  if (evaluating) {
+    evaluating->UpdateState(ServiceWorkerState::Redundant);
+    evaluating->UpdateRedundantTime();
+    evaluating->WorkerPrivate()->NoteDeadServiceWorkerInfo();
+  }
+
   if (installing) {
     installing->UpdateState(ServiceWorkerState::Redundant);
     installing->UpdateRedundantTime();
     installing->WorkerPrivate()->NoteDeadServiceWorkerInfo();
     // FIXME(nsm): Abort any inflight requests from installing worker.
   }
 
   if (waiting) {