Chromium Code Reviews| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 blink::WebServiceWorkerClientsCallbacks* callbacks) { | 125 blink::WebServiceWorkerClientsCallbacks* callbacks) { |
| 126 DCHECK(script_context_); | 126 DCHECK(script_context_); |
| 127 script_context_->GetClientDocuments(callbacks); | 127 script_context_->GetClientDocuments(callbacks); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void EmbeddedWorkerContextClient::workerContextFailedToStart() { | 130 void EmbeddedWorkerContextClient::workerContextFailedToStart() { |
| 131 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); | 131 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 132 DCHECK(!script_context_); | 132 DCHECK(!script_context_); |
| 133 | 133 |
| 134 RenderThreadImpl::current()->embedded_worker_dispatcher()-> | 134 RenderThreadImpl::current()->embedded_worker_dispatcher()-> |
| 135 WorkerContextDestroyed(embedded_worker_id_); | 135 WorkerContextDestroyed(embedded_worker_id_); |
|
kinuko
2014/05/02 07:27:10
While you're there... it might be better to send W
horo
2014/05/02 08:04:56
Done.
| |
| 136 } | 136 } |
| 137 | 137 |
| 138 void EmbeddedWorkerContextClient::workerContextStarted( | 138 void EmbeddedWorkerContextClient::workerContextStarted( |
| 139 blink::WebServiceWorkerContextProxy* proxy) { | 139 blink::WebServiceWorkerContextProxy* proxy) { |
| 140 DCHECK(!worker_task_runner_); | 140 DCHECK(!worker_task_runner_); |
| 141 worker_task_runner_ = new WorkerThreadTaskRunner( | 141 worker_task_runner_ = new WorkerThreadTaskRunner( |
| 142 WorkerTaskRunner::Instance()->CurrentWorkerId()); | 142 WorkerTaskRunner::Instance()->CurrentWorkerId()); |
| 143 DCHECK_NE(0, WorkerTaskRunner::Instance()->CurrentWorkerId()); | 143 DCHECK_NE(0, WorkerTaskRunner::Instance()->CurrentWorkerId()); |
| 144 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 144 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
| 145 DCHECK(!script_context_); | 145 DCHECK(!script_context_); |
| 146 g_worker_client_tls.Pointer()->Set(this); | 146 g_worker_client_tls.Pointer()->Set(this); |
| 147 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); | 147 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); |
| 148 | 148 |
| 149 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded(embedded_worker_id_)); | |
| 150 | |
| 149 // Schedule a task to send back WorkerStarted asynchronously, | 151 // Schedule a task to send back WorkerStarted asynchronously, |
| 150 // so that at the time we send it we can be sure that the worker | 152 // so that at the time we send it we can be sure that the worker |
| 151 // script has been evaluated and worker run loop has been started. | 153 // script has been evaluated and worker run loop has been started. |
| 152 worker_task_runner_->PostTask( | 154 worker_task_runner_->PostTask( |
| 153 FROM_HERE, | 155 FROM_HERE, |
| 154 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, | 156 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, |
| 155 weak_factory_.GetWeakPtr())); | 157 weak_factory_.GetWeakPtr())); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void EmbeddedWorkerContextClient::willDestroyWorkerContext() { | 160 void EmbeddedWorkerContextClient::willDestroyWorkerContext() { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 } | 279 } |
| 278 | 280 |
| 279 void EmbeddedWorkerContextClient::SendWorkerStarted() { | 281 void EmbeddedWorkerContextClient::SendWorkerStarted() { |
| 280 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 282 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 281 Send(new EmbeddedWorkerHostMsg_WorkerStarted( | 283 Send(new EmbeddedWorkerHostMsg_WorkerStarted( |
| 282 WorkerTaskRunner::Instance()->CurrentWorkerId(), | 284 WorkerTaskRunner::Instance()->CurrentWorkerId(), |
| 283 embedded_worker_id_)); | 285 embedded_worker_id_)); |
| 284 } | 286 } |
| 285 | 287 |
| 286 } // namespace content | 288 } // namespace content |
| OLD | NEW |