From ae22e882e62d94b3095895a24e36da3a27799ffe Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 22 Dec 2017 21:09:19 -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 7a47455a32ce..98e833346fe6 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,