Bug 1425975 P4 Make ServiceWorkerManager::UpdateClientControllers use mControlledClients. r=asuth
authorBen Kelly <ben@wanderview.com>
Fri, 05 Jan 2018 12:10:20 -0500
changeset 449768 d432082aabbd1aaf685263eb265748e2ae043d01
parent 449767 818fd73be280cca813edeea710596876ce91f234
child 449769 560f15a8009772f7b237c666e28fac92198f2c9b
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1425975
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425975 P4 Make ServiceWorkerManager::UpdateClientControllers use mControlledClients. r=asuth
dom/workers/ServiceWorkerManager.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -3304,41 +3304,29 @@ ServiceWorkerManager::SetSkipWaitingFlag
 void
 ServiceWorkerManager::UpdateClientControllers(ServiceWorkerRegistrationInfo* aRegistration)
 {
   AssertIsOnMainThread();
 
   RefPtr<ServiceWorkerInfo> activeWorker = aRegistration->GetActive();
   MOZ_DIAGNOSTIC_ASSERT(activeWorker);
 
-  AutoTArray<nsCOMPtr<nsIDocument>, 16> docList;
-  for (auto iter = mControlledDocuments.Iter(); !iter.Done(); iter.Next()) {
-    if (iter.UserData() != aRegistration) {
-      continue;
-    }
-
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(iter.Key());
-    if (NS_WARN_IF(!doc)) {
+  AutoTArray<RefPtr<ClientHandle>, 16> handleList;
+  for (auto iter = mControlledClients.Iter(); !iter.Done(); iter.Next()) {
+    if (iter.UserData()->mRegistrationInfo != aRegistration) {
       continue;
     }
 
-    docList.AppendElement(doc.forget());
+    handleList.AppendElement(iter.UserData()->mClientHandle);
   }
 
-  // Fire event after iterating mControlledDocuments is done to prevent
+  // Fire event after iterating mControlledClients is done to prevent
   // modification by reentering from the event handlers during iteration.
-  for (auto& doc : docList) {
-    Maybe<ClientInfo> clientInfo = doc->GetClientInfo();
-    if (clientInfo.isNothing()) {
-      continue;
-    }
-    RefPtr<ClientHandle> clientHandle =
-      ClientManager::CreateHandle(clientInfo.ref(),
-                                  SystemGroup::EventTargetFor(TaskCategory::Other));
-    clientHandle->Control(activeWorker->Descriptor());
+  for (auto& handle : handleList) {
+    handle->Control(activeWorker->Descriptor());
   }
 }
 
 already_AddRefed<ServiceWorkerRegistrationInfo>
 ServiceWorkerManager::GetRegistration(nsIPrincipal* aPrincipal,
                                       const nsACString& aScope) const
 {
   MOZ_ASSERT(aPrincipal);