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

Side by Side Diff: content/renderer/service_worker/embedded_worker_context_client.cc

Issue 855383006: ServiceWorker: Enqueue state change events until the worker thread gets ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix content_unittests Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/service_worker/embedded_worker_context_client.h" 5 #include "content/renderer/service_worker/embedded_worker_context_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 // This can be nullptr on EmbeddedWorkerBrowserTests. 183 // This can be nullptr on EmbeddedWorkerBrowserTests.
184 // TODO(nhiroki): Remove this workaround. |registration()| should always be 184 // TODO(nhiroki): Remove this workaround. |registration()| should always be
185 // valid other than the test because the registration association message 185 // valid other than the test because the registration association message
186 // arrives before starting the worker context. 186 // arrives before starting the worker context.
187 if (provider_context_->registration()) 187 if (provider_context_->registration())
188 SetRegistrationInServiceWorkerGlobalScope(); 188 SetRegistrationInServiceWorkerGlobalScope();
189 189
190 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( 190 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded(
191 embedded_worker_id_, 191 embedded_worker_id_,
192 WorkerTaskRunner::Instance()->CurrentWorkerId())); 192 WorkerTaskRunner::Instance()->CurrentWorkerId(),
193 provider_context_->provider_id()));
193 194
194 // Schedule a task to send back WorkerStarted asynchronously, 195 // Schedule a task to send back WorkerStarted asynchronously,
195 // so that at the time we send it we can be sure that the worker 196 // so that at the time we send it we can be sure that the worker
196 // script has been evaluated and worker run loop has been started. 197 // script has been evaluated and worker run loop has been started.
197 worker_task_runner_->PostTask( 198 worker_task_runner_->PostTask(
198 FROM_HERE, 199 FROM_HERE,
199 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, 200 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted,
200 weak_factory_.GetWeakPtr())); 201 weak_factory_.GetWeakPtr()));
201 TRACE_EVENT_ASYNC_STEP_INTO0( 202 TRACE_EVENT_ASYNC_STEP_INTO0(
202 "ServiceWorker", 203 "ServiceWorker",
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 registration->SetWaiting( 438 registration->SetWaiting(
438 dispatcher->GetServiceWorker(attrs.waiting, false)); 439 dispatcher->GetServiceWorker(attrs.waiting, false));
439 registration->SetActive( 440 registration->SetActive(
440 dispatcher->GetServiceWorker(attrs.active, false)); 441 dispatcher->GetServiceWorker(attrs.active, false));
441 442
442 script_context_->SetRegistrationInServiceWorkerGlobalScope( 443 script_context_->SetRegistrationInServiceWorkerGlobalScope(
443 registration.Pass()); 444 registration.Pass());
444 } 445 }
445 446
446 } // namespace content 447 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698