From 9354f0db20b45ab80fedf099893211fb03a25b01 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 5 Jan 2018 12:10:20 -0500 Subject: [PATCH] Bug 1425975 P4 Make ServiceWorkerManager::UpdateClientControllers use mControlledClients. r=asuth --- dom/workers/ServiceWorkerManager.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 76737b98c524..1d386796a485 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -3309,31 +3309,19 @@ ServiceWorkerManager::UpdateClientControllers(ServiceWorkerRegistrationInfo* aRe RefPtr activeWorker = aRegistration->GetActive(); MOZ_DIAGNOSTIC_ASSERT(activeWorker); - AutoTArray, 16> docList; - for (auto iter = mControlledDocuments.Iter(); !iter.Done(); iter.Next()) { - if (iter.UserData() != aRegistration) { + AutoTArray, 16> handleList; + for (auto iter = mControlledClients.Iter(); !iter.Done(); iter.Next()) { + if (iter.UserData()->mRegistrationInfo != aRegistration) { continue; } - nsCOMPtr doc = do_QueryInterface(iter.Key()); - if (NS_WARN_IF(!doc)) { - 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 = doc->GetClientInfo(); - if (clientInfo.isNothing()) { - continue; - } - RefPtr clientHandle = - ClientManager::CreateHandle(clientInfo.ref(), - SystemGroup::EventTargetFor(TaskCategory::Other)); - clientHandle->Control(activeWorker->Descriptor()); + for (auto& handle : handleList) { + handle->Control(activeWorker->Descriptor()); } }