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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/child/service_worker/service_worker_handle_reference.h" | 21 #include "content/child/service_worker/service_worker_handle_reference.h" |
22 #include "content/child/service_worker/service_worker_network_provider.h" | 22 #include "content/child/service_worker/service_worker_network_provider.h" |
23 #include "content/child/service_worker/service_worker_provider_context.h" | 23 #include "content/child/service_worker/service_worker_provider_context.h" |
24 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 24 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
25 #include "content/child/service_worker/web_service_worker_impl.h" | 25 #include "content/child/service_worker/web_service_worker_impl.h" |
26 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 26 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
27 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 27 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
28 #include "content/child/thread_safe_sender.h" | 28 #include "content/child/thread_safe_sender.h" |
29 #include "content/child/webmessageportchannel_impl.h" | 29 #include "content/child/webmessageportchannel_impl.h" |
30 #include "content/common/devtools_messages.h" | 30 #include "content/common/devtools_messages.h" |
31 #include "content/common/geofencing_messages.h" | |
32 #include "content/common/message_port_messages.h" | 31 #include "content/common/message_port_messages.h" |
33 #include "content/common/mojo/service_registry_impl.h" | 32 #include "content/common/mojo/service_registry_impl.h" |
34 #include "content/common/service_worker/embedded_worker_messages.h" | 33 #include "content/common/service_worker/embedded_worker_messages.h" |
35 #include "content/common/service_worker/service_worker_messages.h" | 34 #include "content/common/service_worker/service_worker_messages.h" |
36 #include "content/public/common/push_event_payload.h" | 35 #include "content/public/common/push_event_payload.h" |
37 #include "content/public/common/referrer.h" | 36 #include "content/public/common/referrer.h" |
38 #include "content/public/renderer/content_renderer_client.h" | 37 #include "content/public/renderer/content_renderer_client.h" |
39 #include "content/public/renderer/document_state.h" | 38 #include "content/public/renderer/document_state.h" |
40 #include "content/renderer/background_sync/background_sync_client_impl.h" | 39 #include "content/renderer/background_sync/background_sync_client_impl.h" |
41 #include "content/renderer/devtools/devtools_agent.h" | 40 #include "content/renderer/devtools/devtools_agent.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent) | 244 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent) |
246 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ExtendableMessageEvent, | 245 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ExtendableMessageEvent, |
247 OnExtendableMessageEvent) | 246 OnExtendableMessageEvent) |
248 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent) | 247 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent) |
249 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEvent) | 248 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEvent) |
250 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent, | 249 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent, |
251 OnNotificationClickEvent) | 250 OnNotificationClickEvent) |
252 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationCloseEvent, | 251 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationCloseEvent, |
253 OnNotificationCloseEvent) | 252 OnNotificationCloseEvent) |
254 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent) | 253 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent) |
255 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GeofencingEvent, OnGeofencingEvent) | |
256 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClient, OnDidGetClient) | 254 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClient, OnDidGetClient) |
257 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients, OnDidGetClients) | 255 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients, OnDidGetClients) |
258 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse, | 256 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse, |
259 OnOpenWindowResponse) | 257 OnOpenWindowResponse) |
260 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowError, | 258 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowError, |
261 OnOpenWindowError) | 259 OnOpenWindowError) |
262 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse, | 260 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse, |
263 OnFocusClientResponse) | 261 OnFocusClientResponse) |
264 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NavigateClientResponse, | 262 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NavigateClientResponse, |
265 OnNavigateClientResponse) | 263 OnNavigateClientResponse) |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 const PushEventPayload& payload) { | 814 const PushEventPayload& payload) { |
817 TRACE_EVENT0("ServiceWorker", | 815 TRACE_EVENT0("ServiceWorker", |
818 "ServiceWorkerContextClient::OnPushEvent"); | 816 "ServiceWorkerContextClient::OnPushEvent"); |
819 // Only set data to be a valid string if the payload had decrypted data. | 817 // Only set data to be a valid string if the payload had decrypted data. |
820 blink::WebString data; | 818 blink::WebString data; |
821 if (!payload.is_null) | 819 if (!payload.is_null) |
822 data.assign(blink::WebString::fromUTF8(payload.data)); | 820 data.assign(blink::WebString::fromUTF8(payload.data)); |
823 proxy_->dispatchPushEvent(request_id, data); | 821 proxy_->dispatchPushEvent(request_id, data); |
824 } | 822 } |
825 | 823 |
826 void ServiceWorkerContextClient::OnGeofencingEvent( | |
827 int request_id, | |
828 blink::WebGeofencingEventType event_type, | |
829 const std::string& region_id, | |
830 const blink::WebCircularGeofencingRegion& region) { | |
831 TRACE_EVENT0("ServiceWorker", | |
832 "ServiceWorkerContextClient::OnGeofencingEvent"); | |
833 proxy_->dispatchGeofencingEvent( | |
834 request_id, event_type, blink::WebString::fromUTF8(region_id), region); | |
835 Send(new ServiceWorkerHostMsg_GeofencingEventFinished( | |
836 GetRoutingID(), request_id, blink::WebServiceWorkerEventResultCompleted)); | |
837 } | |
838 | |
839 void ServiceWorkerContextClient::OnDidGetClient( | 824 void ServiceWorkerContextClient::OnDidGetClient( |
840 int request_id, | 825 int request_id, |
841 const ServiceWorkerClientInfo& client) { | 826 const ServiceWorkerClientInfo& client) { |
842 TRACE_EVENT0("ServiceWorker", "ServiceWorkerContextClient::OnDidGetClient"); | 827 TRACE_EVENT0("ServiceWorker", "ServiceWorkerContextClient::OnDidGetClient"); |
843 blink::WebServiceWorkerClientCallbacks* callbacks = | 828 blink::WebServiceWorkerClientCallbacks* callbacks = |
844 context_->client_callbacks.Lookup(request_id); | 829 context_->client_callbacks.Lookup(request_id); |
845 if (!callbacks) { | 830 if (!callbacks) { |
846 NOTREACHED() << "Got stray response: " << request_id; | 831 NOTREACHED() << "Got stray response: " << request_id; |
847 return; | 832 return; |
848 } | 833 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } | 1009 } |
1025 | 1010 |
1026 base::WeakPtr<ServiceWorkerContextClient> | 1011 base::WeakPtr<ServiceWorkerContextClient> |
1027 ServiceWorkerContextClient::GetWeakPtr() { | 1012 ServiceWorkerContextClient::GetWeakPtr() { |
1028 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1013 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
1029 DCHECK(context_); | 1014 DCHECK(context_); |
1030 return context_->weak_factory.GetWeakPtr(); | 1015 return context_->weak_factory.GetWeakPtr(); |
1031 } | 1016 } |
1032 | 1017 |
1033 } // namespace content | 1018 } // namespace content |
OLD | NEW |