From 3bd443575939c197bb5ae228baf7591e3491931f Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 5 Jan 2018 12:10:21 -0500 Subject: [PATCH] Bug 1425975 P9 Refactor MaybeCheckNavigationUpdate() to take a ClientInfo instead of a document. r=asuth --- dom/base/nsDocument.cpp | 5 ++++- dom/workers/ServiceWorkerManager.cpp | 10 ++++------ dom/workers/ServiceWorkerManager.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 54d2f32f93e8..6c18f1711184 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -5599,7 +5599,10 @@ nsDocument::DispatchContentLoadedEvents() using mozilla::dom::workers::ServiceWorkerManager; RefPtr swm = ServiceWorkerManager::GetInstance(); if (swm) { - swm->MaybeCheckNavigationUpdate(this); + Maybe clientInfo = GetClientInfo(); + if (clientInfo.isSome()) { + swm->MaybeCheckNavigationUpdate(clientInfo.ref()); + } } } diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index f358b928e2f2..36da2de9d46b 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -2432,10 +2432,9 @@ ServiceWorkerManager::MaybeStopControlling(nsIDocument* aDoc) } void -ServiceWorkerManager::MaybeCheckNavigationUpdate(nsIDocument* aDoc) +ServiceWorkerManager::MaybeCheckNavigationUpdate(const ClientInfo& aClientInfo) { AssertIsOnMainThread(); - MOZ_ASSERT(aDoc); // We perform these success path navigation update steps when the // document tells us its more or less done loading. This avoids // slowing down page load and also lets pages consistently get @@ -2445,10 +2444,9 @@ ServiceWorkerManager::MaybeCheckNavigationUpdate(nsIDocument* aDoc) // 9.8.22 Else: (respondWith was entered and succeeded) // If request is a non-subresource request, then: Invoke Soft Update // algorithm. - RefPtr registration; - mControlledDocuments.Get(aDoc, getter_AddRefs(registration)); - if (registration) { - registration->MaybeScheduleUpdate(); + ControlledClientData* data = mControlledClients.Get(aClientInfo.Id()); + if (data && data->mRegistrationInfo) { + data->mRegistrationInfo->MaybeScheduleUpdate(); } } diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h index 2596e71b1e01..24f044752524 100644 --- a/dom/workers/ServiceWorkerManager.h +++ b/dom/workers/ServiceWorkerManager.h @@ -320,7 +320,7 @@ public: ServiceWorkerRegistrationListener* aListener); void - MaybeCheckNavigationUpdate(nsIDocument* aDoc); + MaybeCheckNavigationUpdate(const ClientInfo& aClientInfo); nsresult SendPushEvent(const nsACString& aOriginAttributes,