OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/service_worker_context_client.h" | 5 #include "content/renderer/service_worker/service_worker_context_client.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "content/child/notifications/notification_data_conversions.h" | 15 #include "content/child/notifications/notification_data_conversions.h" |
16 #include "content/child/request_extra_data.h" | 16 #include "content/child/request_extra_data.h" |
17 #include "content/child/service_worker/service_worker_dispatcher.h" | 17 #include "content/child/service_worker/service_worker_dispatcher.h" |
18 #include "content/child/service_worker/service_worker_network_provider.h" | 18 #include "content/child/service_worker/service_worker_network_provider.h" |
19 #include "content/child/service_worker/service_worker_provider_context.h" | 19 #include "content/child/service_worker/service_worker_provider_context.h" |
20 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" | 20 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" |
21 #include "content/child/service_worker/web_service_worker_impl.h" | 21 #include "content/child/service_worker/web_service_worker_impl.h" |
22 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 22 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
23 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 23 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
24 #include "content/child/thread_safe_sender.h" | 24 #include "content/child/thread_safe_sender.h" |
25 #include "content/child/webmessageportchannel_impl.h" | 25 #include "content/child/webmessageportchannel_impl.h" |
26 #include "content/child/worker_task_runner.h" | 26 #include "content/child/worker_task_runner.h" |
27 #include "content/common/devtools_messages.h" | 27 #include "content/common/devtools_messages.h" |
28 #include "content/common/message_port_messages.h" | 28 #include "content/common/message_port_messages.h" |
29 #include "content/common/mojo/service_registry_impl.h" | |
29 #include "content/common/service_worker/embedded_worker_messages.h" | 30 #include "content/common/service_worker/embedded_worker_messages.h" |
30 #include "content/common/service_worker/service_worker_messages.h" | 31 #include "content/common/service_worker/service_worker_messages.h" |
31 #include "content/public/common/referrer.h" | 32 #include "content/public/common/referrer.h" |
32 #include "content/public/renderer/document_state.h" | 33 #include "content/public/renderer/document_state.h" |
33 #include "content/renderer/devtools/devtools_agent.h" | 34 #include "content/renderer/devtools/devtools_agent.h" |
34 #include "content/renderer/render_thread_impl.h" | 35 #include "content/renderer/render_thread_impl.h" |
35 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 36 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
36 #include "content/renderer/service_worker/service_worker_type_util.h" | 37 #include "content/renderer/service_worker/service_worker_type_util.h" |
37 #include "ipc/ipc_message.h" | 38 #include "ipc/ipc_message.h" |
38 #include "ipc/ipc_message_macros.h" | 39 #include "ipc/ipc_message_macros.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 192 |
192 // Pending callbacks for OpenWindow() and FocusClient(). | 193 // Pending callbacks for OpenWindow() and FocusClient(). |
193 ClientCallbacksMap client_callbacks; | 194 ClientCallbacksMap client_callbacks; |
194 | 195 |
195 // Pending callbacks for SkipWaiting(). | 196 // Pending callbacks for SkipWaiting(). |
196 SkipWaitingCallbacksMap skip_waiting_callbacks; | 197 SkipWaitingCallbacksMap skip_waiting_callbacks; |
197 | 198 |
198 // Pending callbacks for ClaimClients(). | 199 // Pending callbacks for ClaimClients(). |
199 ClaimClientsCallbacksMap claim_clients_callbacks; | 200 ClaimClientsCallbacksMap claim_clients_callbacks; |
200 | 201 |
202 ServiceRegistryImpl service_registry; | |
203 | |
201 base::ThreadChecker thread_checker; | 204 base::ThreadChecker thread_checker; |
202 base::WeakPtrFactory<ServiceWorkerContextClient> weak_factory; | 205 base::WeakPtrFactory<ServiceWorkerContextClient> weak_factory; |
203 }; | 206 }; |
204 | 207 |
205 ServiceWorkerContextClient* | 208 ServiceWorkerContextClient* |
206 ServiceWorkerContextClient::ThreadSpecificInstance() { | 209 ServiceWorkerContextClient::ThreadSpecificInstance() { |
207 return g_worker_client_tls.Pointer()->Get(); | 210 return g_worker_client_tls.Pointer()->Get(); |
208 } | 211 } |
209 | 212 |
210 ServiceWorkerContextClient::ServiceWorkerContextClient( | 213 ServiceWorkerContextClient::ServiceWorkerContextClient( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 OnFocusClientResponse) | 267 OnFocusClientResponse) |
265 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting) | 268 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting) |
266 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients) | 269 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients) |
267 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError) | 270 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError) |
268 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing); | 271 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing); |
269 IPC_MESSAGE_UNHANDLED(handled = false) | 272 IPC_MESSAGE_UNHANDLED(handled = false) |
270 IPC_END_MESSAGE_MAP() | 273 IPC_END_MESSAGE_MAP() |
271 DCHECK(handled); | 274 DCHECK(handled); |
272 } | 275 } |
273 | 276 |
277 void ServiceWorkerContextClient::BindServiceRegistry( | |
278 mojo::InterfaceRequest<mojo::ServiceProvider> services, | |
279 mojo::ServiceProviderPtr exposed_services) { | |
280 context_->service_registry.Bind(services.Pass()); | |
281 context_->service_registry.BindRemoteServiceProvider(exposed_services.Pass()); | |
kinuko
2015/07/16 15:29:41
nit: could we have a short helpful comment to note
| |
282 } | |
283 | |
274 blink::WebURL ServiceWorkerContextClient::scope() const { | 284 blink::WebURL ServiceWorkerContextClient::scope() const { |
275 return service_worker_scope_; | 285 return service_worker_scope_; |
276 } | 286 } |
277 | 287 |
278 void ServiceWorkerContextClient::getClients( | 288 void ServiceWorkerContextClient::getClients( |
279 const blink::WebServiceWorkerClientQueryOptions& weboptions, | 289 const blink::WebServiceWorkerClientQueryOptions& weboptions, |
280 blink::WebServiceWorkerClientsCallbacks* callbacks) { | 290 blink::WebServiceWorkerClientsCallbacks* callbacks) { |
281 DCHECK(callbacks); | 291 DCHECK(callbacks); |
282 int request_id = context_->clients_callbacks.Add(callbacks); | 292 int request_id = context_->clients_callbacks.Add(callbacks); |
283 ServiceWorkerClientQueryOptions options; | 293 ServiceWorkerClientQueryOptions options; |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 } | 938 } |
929 | 939 |
930 base::WeakPtr<ServiceWorkerContextClient> | 940 base::WeakPtr<ServiceWorkerContextClient> |
931 ServiceWorkerContextClient::GetWeakPtr() { | 941 ServiceWorkerContextClient::GetWeakPtr() { |
932 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 942 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
933 DCHECK(context_); | 943 DCHECK(context_); |
934 return context_->weak_factory.GetWeakPtr(); | 944 return context_->weak_factory.GetWeakPtr(); |
935 } | 945 } |
936 | 946 |
937 } // namespace content | 947 } // namespace content |
OLD | NEW |