| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "content/child/notifications/notification_data_conversions.h" | |
| 19 #include "content/child/request_extra_data.h" | 18 #include "content/child/request_extra_data.h" |
| 20 #include "content/child/service_worker/service_worker_dispatcher.h" | 19 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 21 #include "content/child/service_worker/service_worker_handle_reference.h" | 20 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 22 #include "content/child/service_worker/service_worker_network_provider.h" | 21 #include "content/child/service_worker/service_worker_network_provider.h" |
| 23 #include "content/child/service_worker/service_worker_provider_context.h" | 22 #include "content/child/service_worker/service_worker_provider_context.h" |
| 24 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 23 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
| 25 #include "content/child/service_worker/web_service_worker_impl.h" | 24 #include "content/child/service_worker/web_service_worker_impl.h" |
| 26 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 25 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 27 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 26 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 28 #include "content/child/thread_safe_sender.h" | 27 #include "content/child/thread_safe_sender.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 42 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 44 #include "content/renderer/service_worker/service_worker_type_util.h" | 43 #include "content/renderer/service_worker/service_worker_type_util.h" |
| 45 #include "ipc/ipc_message.h" | 44 #include "ipc/ipc_message.h" |
| 46 #include "ipc/ipc_message_macros.h" | 45 #include "ipc/ipc_message_macros.h" |
| 47 #include "third_party/WebKit/public/platform/URLConversion.h" | 46 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 48 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 47 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 49 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 48 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 50 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 49 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 51 #include "third_party/WebKit/public/platform/WebString.h" | 50 #include "third_party/WebKit/public/platform/WebString.h" |
| 52 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" | 51 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" |
| 53 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" | |
| 54 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" | 52 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" |
| 55 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRequest.h" | 53 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerRequest.h" |
| 56 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponse.h" | 54 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponse.h" |
| 57 #include "third_party/WebKit/public/web/WebDataSource.h" | 55 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 58 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextClient.h" | 56 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextClient.h" |
| 59 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" | 57 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" |
| 60 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerNe
tworkProvider.h" | 58 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerNe
tworkProvider.h" |
| 61 | 59 |
| 62 namespace content { | 60 namespace content { |
| 63 | 61 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 785 } |
| 788 } | 786 } |
| 789 | 787 |
| 790 void ServiceWorkerContextClient::OnNotificationClickEvent( | 788 void ServiceWorkerContextClient::OnNotificationClickEvent( |
| 791 int request_id, | 789 int request_id, |
| 792 int64_t persistent_notification_id, | 790 int64_t persistent_notification_id, |
| 793 const PlatformNotificationData& notification_data, | 791 const PlatformNotificationData& notification_data, |
| 794 int action_index) { | 792 int action_index) { |
| 795 TRACE_EVENT0("ServiceWorker", | 793 TRACE_EVENT0("ServiceWorker", |
| 796 "ServiceWorkerContextClient::OnNotificationClickEvent"); | 794 "ServiceWorkerContextClient::OnNotificationClickEvent"); |
| 795 /** |
| 797 proxy_->dispatchNotificationClickEvent( | 796 proxy_->dispatchNotificationClickEvent( |
| 798 request_id, | 797 request_id, |
| 799 persistent_notification_id, | 798 persistent_notification_id, |
| 800 ToWebNotificationData(notification_data), | 799 __mojo__notification__thing__ |
| 801 action_index); | 800 action_index); |
| 801 **/ |
| 802 } | 802 } |
| 803 | 803 |
| 804 void ServiceWorkerContextClient::OnNotificationCloseEvent( | 804 void ServiceWorkerContextClient::OnNotificationCloseEvent( |
| 805 int request_id, | 805 int request_id, |
| 806 int64_t persistent_notification_id, | 806 int64_t persistent_notification_id, |
| 807 const PlatformNotificationData& notification_data) { | 807 const PlatformNotificationData& notification_data) { |
| 808 TRACE_EVENT0("ServiceWorker", | 808 TRACE_EVENT0("ServiceWorker", |
| 809 "ServiceWorkerContextClient::OnNotificationCloseEvent"); | 809 "ServiceWorkerContextClient::OnNotificationCloseEvent"); |
| 810 /** |
| 810 proxy_->dispatchNotificationCloseEvent( | 811 proxy_->dispatchNotificationCloseEvent( |
| 811 request_id, persistent_notification_id, | 812 request_id, persistent_notification_id, |
| 812 ToWebNotificationData(notification_data)); | 813 __mojo__notification__thing__); |
| 814 **/ |
| 813 } | 815 } |
| 814 | 816 |
| 815 void ServiceWorkerContextClient::OnPushEvent(int request_id, | 817 void ServiceWorkerContextClient::OnPushEvent(int request_id, |
| 816 const PushEventPayload& payload) { | 818 const PushEventPayload& payload) { |
| 817 TRACE_EVENT0("ServiceWorker", | 819 TRACE_EVENT0("ServiceWorker", |
| 818 "ServiceWorkerContextClient::OnPushEvent"); | 820 "ServiceWorkerContextClient::OnPushEvent"); |
| 819 // Only set data to be a valid string if the payload had decrypted data. | 821 // Only set data to be a valid string if the payload had decrypted data. |
| 820 blink::WebString data; | 822 blink::WebString data; |
| 821 if (!payload.is_null) | 823 if (!payload.is_null) |
| 822 data.assign(blink::WebString::fromUTF8(payload.data)); | 824 data.assign(blink::WebString::fromUTF8(payload.data)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 } | 1026 } |
| 1025 | 1027 |
| 1026 base::WeakPtr<ServiceWorkerContextClient> | 1028 base::WeakPtr<ServiceWorkerContextClient> |
| 1027 ServiceWorkerContextClient::GetWeakPtr() { | 1029 ServiceWorkerContextClient::GetWeakPtr() { |
| 1028 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1030 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1029 DCHECK(context_); | 1031 DCHECK(context_); |
| 1030 return context_->weak_factory.GetWeakPtr(); | 1032 return context_->weak_factory.GetWeakPtr(); |
| 1031 } | 1033 } |
| 1032 | 1034 |
| 1033 } // namespace content | 1035 } // namespace content |
| OLD | NEW |