| OLD | NEW |
| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // gets deleted before workerContextStarted() is called. | 177 // gets deleted before workerContextStarted() is called. |
| 178 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 178 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 179 DCHECK(!script_context_); | 179 DCHECK(!script_context_); |
| 180 g_worker_client_tls.Pointer()->Set(this); | 180 g_worker_client_tls.Pointer()->Set(this); |
| 181 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); | 181 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); |
| 182 | 182 |
| 183 SetRegistrationInServiceWorkerGlobalScope(); | 183 SetRegistrationInServiceWorkerGlobalScope(); |
| 184 | 184 |
| 185 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( | 185 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( |
| 186 embedded_worker_id_, | 186 embedded_worker_id_, |
| 187 WorkerTaskRunner::Instance()->CurrentWorkerId())); | 187 WorkerTaskRunner::Instance()->CurrentWorkerId(), |
| 188 provider_context_->provider_id())); |
| 188 | 189 |
| 189 // Schedule a task to send back WorkerStarted asynchronously, | 190 // Schedule a task to send back WorkerStarted asynchronously, |
| 190 // so that at the time we send it we can be sure that the worker | 191 // so that at the time we send it we can be sure that the worker |
| 191 // script has been evaluated and worker run loop has been started. | 192 // script has been evaluated and worker run loop has been started. |
| 192 worker_task_runner_->PostTask( | 193 worker_task_runner_->PostTask( |
| 193 FROM_HERE, | 194 FROM_HERE, |
| 194 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, | 195 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, |
| 195 weak_factory_.GetWeakPtr())); | 196 weak_factory_.GetWeakPtr())); |
| 196 TRACE_EVENT_ASYNC_STEP_INTO0( | 197 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 197 "ServiceWorker", | 198 "ServiceWorker", |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 registration->SetWaiting( | 435 registration->SetWaiting( |
| 435 dispatcher->GetServiceWorker(attrs.waiting, false)); | 436 dispatcher->GetServiceWorker(attrs.waiting, false)); |
| 436 registration->SetActive( | 437 registration->SetActive( |
| 437 dispatcher->GetServiceWorker(attrs.active, false)); | 438 dispatcher->GetServiceWorker(attrs.active, false)); |
| 438 | 439 |
| 439 script_context_->SetRegistrationInServiceWorkerGlobalScope( | 440 script_context_->SetRegistrationInServiceWorkerGlobalScope( |
| 440 registration.Pass()); | 441 registration.Pass()); |
| 441 } | 442 } |
| 442 | 443 |
| 443 } // namespace content | 444 } // namespace content |
| OLD | NEW |