Bug 1438211 P5 Replace direct window/worker calls with nsIGlobalObject::GetOrCreateServiceWorkerRegistration(). r=asuth

--HG--
extra : rebase_source : 2b0f83a5e5a6e5eeac9e1401168c6653b6250c23
This commit is contained in:
Ben Kelly 2018-03-02 13:02:50 -08:00
parent b7cbf79c03
commit 5706606e9b
2 changed files with 5 additions and 7 deletions

View File

@ -467,7 +467,7 @@ class ServiceWorkerResolveWindowPromiseOnRegisterCallback final : public Service
RefPtr<ServiceWorkerRegistrationInfo> reg = registerJob->GetRegistration();
RefPtr<ServiceWorkerRegistration> swr =
window->GetServiceWorkerRegistration(reg->Descriptor());
window->AsGlobal()->GetOrCreateServiceWorkerRegistration(reg->Descriptor());
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"ServiceWorkerResolveWindowPromiseOnRegisterCallback::JobFinished",
@ -1031,7 +1031,7 @@ public:
}
RefPtr<ServiceWorkerRegistration> swr =
mWindow->GetServiceWorkerRegistration(info->Descriptor());
mWindow->AsGlobal()->GetOrCreateServiceWorkerRegistration(info->Descriptor());
array.AppendElement(swr);
}
@ -1154,7 +1154,7 @@ public:
}
RefPtr<ServiceWorkerRegistration> swr =
mWindow->GetServiceWorkerRegistration(registration->Descriptor());
mWindow->AsGlobal()->GetOrCreateServiceWorkerRegistration(registration->Descriptor());
mPromise->MaybeResolve(swr);
return NS_OK;
@ -1468,7 +1468,7 @@ ServiceWorkerManager::CheckReadyPromise(nsPIDOMWindowInner* aWindow,
if (registration && registration->GetActive()) {
RefPtr<ServiceWorkerRegistration> swr =
aWindow->GetServiceWorkerRegistration(registration->Descriptor());
aWindow->AsGlobal()->GetOrCreateServiceWorkerRegistration(registration->Descriptor());
aPromise->MaybeResolve(swr);
return true;
}

View File

@ -685,9 +685,7 @@ ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate
// Eagerly create the registration because we will need to receive updates
// about the state of the registration. We can't wait until first access
// to start receiving these.
, mRegistration(ServiceWorkerRegistration::CreateForWorker(aWorkerPrivate,
this,
aRegistrationDescriptor))
, mRegistration(GetOrCreateServiceWorkerRegistration(aRegistrationDescriptor))
{
}