Skip to content

Commit

Permalink
Bug 1438211 P5 Replace direct window/worker calls with nsIGlobalObjec…
Browse files Browse the repository at this point in the history
…t::GetOrCreateServiceWorkerRegistration(). r=asuth

--HG--
extra : rebase_source : 2b0f83a5e5a6e5eeac9e1401168c6653b6250c23
  • Loading branch information
wanderview committed Mar 2, 2018
1 parent b7cbf79 commit 5706606
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dom/serviceworkers/ServiceWorkerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1031,7 +1031,7 @@ class GetRegistrationsRunnable final : public Runnable
}

RefPtr<ServiceWorkerRegistration> swr =
mWindow->GetServiceWorkerRegistration(info->Descriptor());
mWindow->AsGlobal()->GetOrCreateServiceWorkerRegistration(info->Descriptor());

array.AppendElement(swr);
}
Expand Down Expand Up @@ -1154,7 +1154,7 @@ class GetRegistrationRunnable final : public Runnable
}

RefPtr<ServiceWorkerRegistration> swr =
mWindow->GetServiceWorkerRegistration(registration->Descriptor());
mWindow->AsGlobal()->GetOrCreateServiceWorkerRegistration(registration->Descriptor());
mPromise->MaybeResolve(swr);

return NS_OK;
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions dom/workers/WorkerScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
}

Expand Down

0 comments on commit 5706606

Please sign in to comment.