Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 25 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 26 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 26 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 27 #include "content/child/thread_safe_sender.h" | 27 #include "content/child/thread_safe_sender.h" |
| 28 #include "content/child/webmessageportchannel_impl.h" | 28 #include "content/child/webmessageportchannel_impl.h" |
| 29 #include "content/common/devtools_messages.h" | 29 #include "content/common/devtools_messages.h" |
| 30 #include "content/common/geofencing_messages.h" | 30 #include "content/common/geofencing_messages.h" |
| 31 #include "content/common/message_port_messages.h" | 31 #include "content/common/message_port_messages.h" |
| 32 #include "content/common/mojo/service_registry_impl.h" | 32 #include "content/common/mojo/service_registry_impl.h" |
| 33 #include "content/common/service_worker/embedded_worker_messages.h" | 33 #include "content/common/service_worker/embedded_worker_messages.h" |
| 34 #include "content/common/service_worker/service_worker_messages.h" | 34 #include "content/common/service_worker/service_worker_messages.h" |
| 35 #include "content/public/common/push_event_payload.h" | |
| 35 #include "content/public/common/referrer.h" | 36 #include "content/public/common/referrer.h" |
| 36 #include "content/public/renderer/content_renderer_client.h" | 37 #include "content/public/renderer/content_renderer_client.h" |
| 37 #include "content/public/renderer/document_state.h" | 38 #include "content/public/renderer/document_state.h" |
| 38 #include "content/renderer/background_sync/background_sync_client_impl.h" | 39 #include "content/renderer/background_sync/background_sync_client_impl.h" |
| 39 #include "content/renderer/devtools/devtools_agent.h" | 40 #include "content/renderer/devtools/devtools_agent.h" |
| 40 #include "content/renderer/render_thread_impl.h" | 41 #include "content/renderer/render_thread_impl.h" |
| 41 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 42 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 42 #include "content/renderer/service_worker/service_worker_type_util.h" | 43 #include "content/renderer/service_worker/service_worker_type_util.h" |
| 43 #include "ipc/ipc_message.h" | 44 #include "ipc/ipc_message.h" |
| 44 #include "ipc/ipc_message_macros.h" | 45 #include "ipc/ipc_message_macros.h" |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 int action_index) { | 754 int action_index) { |
| 754 TRACE_EVENT0("ServiceWorker", | 755 TRACE_EVENT0("ServiceWorker", |
| 755 "ServiceWorkerContextClient::OnNotificationClickEvent"); | 756 "ServiceWorkerContextClient::OnNotificationClickEvent"); |
| 756 proxy_->dispatchNotificationClickEvent( | 757 proxy_->dispatchNotificationClickEvent( |
| 757 request_id, | 758 request_id, |
| 758 persistent_notification_id, | 759 persistent_notification_id, |
| 759 ToWebNotificationData(notification_data), | 760 ToWebNotificationData(notification_data), |
| 760 action_index); | 761 action_index); |
| 761 } | 762 } |
| 762 | 763 |
| 763 void ServiceWorkerContextClient::OnPushEvent(int request_id, | 764 void ServiceWorkerContextClient::OnPushEvent( |
| 764 const std::string& data) { | 765 int request_id, |
| 766 const content::PushEventPayload& payload) { | |
| 765 TRACE_EVENT0("ServiceWorker", | 767 TRACE_EVENT0("ServiceWorker", |
| 766 "ServiceWorkerContextClient::OnPushEvent"); | 768 "ServiceWorkerContextClient::OnPushEvent"); |
| 767 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); | 769 // Only set data to be a valid string if the payload had decrypted data. |
| 770 blink::WebString data; | |
| 771 if (!payload.isNull()) { | |
|
Peter Beverloo
2016/01/25 17:39:07
micro nit: no curly brackets
harkness
2016/01/26 12:07:20
Done.
| |
| 772 data.assign(blink::WebString::fromUTF8(payload.getData())); | |
| 773 } | |
| 774 proxy_->dispatchPushEvent(request_id, data); | |
| 768 } | 775 } |
| 769 | 776 |
| 770 void ServiceWorkerContextClient::OnGeofencingEvent( | 777 void ServiceWorkerContextClient::OnGeofencingEvent( |
| 771 int request_id, | 778 int request_id, |
| 772 blink::WebGeofencingEventType event_type, | 779 blink::WebGeofencingEventType event_type, |
| 773 const std::string& region_id, | 780 const std::string& region_id, |
| 774 const blink::WebCircularGeofencingRegion& region) { | 781 const blink::WebCircularGeofencingRegion& region) { |
| 775 TRACE_EVENT0("ServiceWorker", | 782 TRACE_EVENT0("ServiceWorker", |
| 776 "ServiceWorkerContextClient::OnGeofencingEvent"); | 783 "ServiceWorkerContextClient::OnGeofencingEvent"); |
| 777 proxy_->dispatchGeofencingEvent( | 784 proxy_->dispatchGeofencingEvent( |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 } | 994 } |
| 988 | 995 |
| 989 base::WeakPtr<ServiceWorkerContextClient> | 996 base::WeakPtr<ServiceWorkerContextClient> |
| 990 ServiceWorkerContextClient::GetWeakPtr() { | 997 ServiceWorkerContextClient::GetWeakPtr() { |
| 991 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 998 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 992 DCHECK(context_); | 999 DCHECK(context_); |
| 993 return context_->weak_factory.GetWeakPtr(); | 1000 return context_->weak_factory.GetWeakPtr(); |
| 994 } | 1001 } |
| 995 | 1002 |
| 996 } // namespace content | 1003 } // namespace content |
| OLD | NEW |