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" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" |
15 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
17 #include "content/child/request_extra_data.h" | 18 #include "content/child/request_extra_data.h" |
18 #include "content/child/service_worker/service_worker_dispatcher.h" | 19 #include "content/child/service_worker/service_worker_dispatcher.h" |
19 #include "content/child/service_worker/service_worker_network_provider.h" | 20 #include "content/child/service_worker/service_worker_network_provider.h" |
20 #include "content/child/service_worker/service_worker_provider_context.h" | 21 #include "content/child/service_worker/service_worker_provider_context.h" |
21 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 22 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
22 #include "content/child/service_worker/web_service_worker_impl.h" | 23 #include "content/child/service_worker/web_service_worker_impl.h" |
23 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 24 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
24 #include "content/child/thread_safe_sender.h" | 25 #include "content/child/thread_safe_sender.h" |
25 #include "content/child/worker_task_runner.h" | 26 #include "content/child/worker_task_runner.h" |
26 #include "content/child/worker_thread_task_runner.h" | |
27 #include "content/common/devtools_messages.h" | 27 #include "content/common/devtools_messages.h" |
28 #include "content/common/service_worker/embedded_worker_messages.h" | 28 #include "content/common/service_worker/embedded_worker_messages.h" |
29 #include "content/common/service_worker/service_worker_types.h" | 29 #include "content/common/service_worker/service_worker_types.h" |
30 #include "content/public/renderer/document_state.h" | 30 #include "content/public/renderer/document_state.h" |
31 #include "content/renderer/devtools/devtools_agent.h" | 31 #include "content/renderer/devtools/devtools_agent.h" |
32 #include "content/renderer/render_thread_impl.h" | 32 #include "content/renderer/render_thread_impl.h" |
33 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 33 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
34 #include "content/renderer/service_worker/service_worker_script_context.h" | 34 #include "content/renderer/service_worker/service_worker_script_context.h" |
35 #include "ipc/ipc_message_macros.h" | 35 #include "ipc/ipc_message_macros.h" |
36 #include "third_party/WebKit/public/platform/WebServiceWorkerResponse.h" | 36 #include "third_party/WebKit/public/platform/WebServiceWorkerResponse.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); | 164 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); |
165 | 165 |
166 RenderThreadImpl::current()->embedded_worker_dispatcher()-> | 166 RenderThreadImpl::current()->embedded_worker_dispatcher()-> |
167 WorkerContextDestroyed(embedded_worker_id_); | 167 WorkerContextDestroyed(embedded_worker_id_); |
168 } | 168 } |
169 | 169 |
170 void EmbeddedWorkerContextClient::workerContextStarted( | 170 void EmbeddedWorkerContextClient::workerContextStarted( |
171 blink::WebServiceWorkerContextProxy* proxy) { | 171 blink::WebServiceWorkerContextProxy* proxy) { |
172 DCHECK(!worker_task_runner_.get()); | 172 DCHECK(!worker_task_runner_.get()); |
173 worker_task_runner_ = new WorkerThreadTaskRunner( | |
174 WorkerTaskRunner::Instance()->CurrentWorkerId()); | |
175 DCHECK_NE(0, WorkerTaskRunner::Instance()->CurrentWorkerId()); | 173 DCHECK_NE(0, WorkerTaskRunner::Instance()->CurrentWorkerId()); |
| 174 worker_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
176 // g_worker_client_tls.Pointer()->Get() could return NULL if this context | 175 // g_worker_client_tls.Pointer()->Get() could return NULL if this context |
177 // gets deleted before workerContextStarted() is called. | 176 // gets deleted before workerContextStarted() is called. |
178 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 177 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
179 DCHECK(!script_context_); | 178 DCHECK(!script_context_); |
180 g_worker_client_tls.Pointer()->Set(this); | 179 g_worker_client_tls.Pointer()->Set(this); |
181 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); | 180 script_context_.reset(new ServiceWorkerScriptContext(this, proxy)); |
182 | 181 |
183 SetRegistrationInServiceWorkerGlobalScope(); | 182 SetRegistrationInServiceWorkerGlobalScope(); |
184 | 183 |
185 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( | 184 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 registration->SetWaiting( | 440 registration->SetWaiting( |
442 dispatcher->GetServiceWorker(attrs.waiting, false)); | 441 dispatcher->GetServiceWorker(attrs.waiting, false)); |
443 registration->SetActive( | 442 registration->SetActive( |
444 dispatcher->GetServiceWorker(attrs.active, false)); | 443 dispatcher->GetServiceWorker(attrs.active, false)); |
445 | 444 |
446 script_context_->SetRegistrationInServiceWorkerGlobalScope( | 445 script_context_->SetRegistrationInServiceWorkerGlobalScope( |
447 registration.Pass()); | 446 registration.Pass()); |
448 } | 447 } |
449 | 448 |
450 } // namespace content | 449 } // namespace content |
OLD | NEW |