Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2991)

Unified Diff: content/renderer/service_worker/embedded_worker_context_client.cc

Issue 885443006: ServiceWorker: Get registration info and its version attributes in one lock operation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/service_worker/web_service_worker_provider_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/embedded_worker_context_client.cc
diff --git a/content/renderer/service_worker/embedded_worker_context_client.cc b/content/renderer/service_worker/embedded_worker_context_client.cc
index ccf3dcce48defaba3f0f1d775b14fde0721beb91..ed22c62bda3b5c7e860f0a6bdeda103cb3093d21 100644
--- a/content/renderer/service_worker/embedded_worker_context_client.cc
+++ b/content/renderer/service_worker/embedded_worker_context_client.cc
@@ -180,12 +180,7 @@ void EmbeddedWorkerContextClient::workerContextStarted(
g_worker_client_tls.Pointer()->Set(this);
script_context_.reset(new ServiceWorkerScriptContext(this, proxy));
- // This can be nullptr on EmbeddedWorkerBrowserTests.
- // TODO(nhiroki): Remove this workaround. |registration()| should always be
- // valid other than the test because the registration association message
- // arrives before starting the worker context.
- if (provider_context_->registration())
- SetRegistrationInServiceWorkerGlobalScope();
+ SetRegistrationInServiceWorkerGlobalScope();
Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded(
embedded_worker_id_,
@@ -419,19 +414,21 @@ void EmbeddedWorkerContextClient::SetRegistrationInServiceWorkerGlobalScope() {
DCHECK(provider_context_);
DCHECK(script_context_);
+ ServiceWorkerRegistrationObjectInfo info;
+ ServiceWorkerVersionAttributes attrs;
+ bool found =
+ provider_context_->GetRegistrationInfoAndVersionAttributes(&info, &attrs);
+ if (!found)
+ return; // Cannot be associated with a registration in some tests.
+
ServiceWorkerDispatcher* dispatcher =
ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
thread_safe_sender());
- // Register a registration with the dispatcher living on the worker thread.
- DCHECK(provider_context_->registration());
+ // Register a registration and its version attributes with the dispatcher
+ // living on the worker thread.
scoped_ptr<WebServiceWorkerRegistrationImpl> registration(
- dispatcher->CreateServiceWorkerRegistration(
- provider_context_->registration()->info(), false));
-
- // Register workers with the dispatcher living on the worker thread.
- ServiceWorkerVersionAttributes attrs =
- provider_context_->GetVersionAttributes();
+ dispatcher->CreateServiceWorkerRegistration(info, false));
registration->SetInstalling(
dispatcher->GetServiceWorker(attrs.installing, false));
registration->SetWaiting(
« no previous file with comments | « content/child/service_worker/web_service_worker_provider_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698