| 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_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 15 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 19 #include "content/child/notifications/notification_data_conversions.h" | 20 #include "content/child/notifications/notification_data_conversions.h" |
| 20 #include "content/child/request_extra_data.h" | 21 #include "content/child/request_extra_data.h" |
| 21 #include "content/child/service_worker/service_worker_dispatcher.h" | 22 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 22 #include "content/child/service_worker/service_worker_handle_reference.h" | 23 #include "content/child/service_worker/service_worker_handle_reference.h" |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 797 |
| 797 void ServiceWorkerContextClient::OnFetchEvent( | 798 void ServiceWorkerContextClient::OnFetchEvent( |
| 798 int response_id, | 799 int response_id, |
| 799 int event_finish_id, | 800 int event_finish_id, |
| 800 const ServiceWorkerFetchRequest& request) { | 801 const ServiceWorkerFetchRequest& request) { |
| 801 blink::WebServiceWorkerRequest webRequest; | 802 blink::WebServiceWorkerRequest webRequest; |
| 802 TRACE_EVENT0("ServiceWorker", "ServiceWorkerContextClient::OnFetchEvent"); | 803 TRACE_EVENT0("ServiceWorker", "ServiceWorkerContextClient::OnFetchEvent"); |
| 803 webRequest.setURL(blink::WebURL(request.url)); | 804 webRequest.setURL(blink::WebURL(request.url)); |
| 804 webRequest.setMethod(blink::WebString::fromUTF8(request.method)); | 805 webRequest.setMethod(blink::WebString::fromUTF8(request.method)); |
| 805 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin(); | 806 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin(); |
| 806 it != request.headers.end(); | 807 it != request.headers.end(); ++it) { |
| 807 ++it) { | |
| 808 webRequest.setHeader(blink::WebString::fromUTF8(it->first), | 808 webRequest.setHeader(blink::WebString::fromUTF8(it->first), |
| 809 blink::WebString::fromUTF8(it->second)); | 809 blink::WebString::fromUTF8(it->second)); |
| 810 } | 810 } |
| 811 if (!request.blob_uuid.empty()) { | 811 if (!request.blob_uuid.empty()) { |
| 812 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), | 812 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), |
| 813 request.blob_size); | 813 request.blob_size); |
| 814 } | 814 } |
| 815 webRequest.setReferrer( | 815 webRequest.setReferrer( |
| 816 blink::WebString::fromUTF8(request.referrer.url.spec()), | 816 blink::WebString::fromUTF8(request.referrer.url.spec()), |
| 817 request.referrer.policy); | 817 request.referrer.policy); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 829 proxy_->dispatchForeignFetchEvent(response_id, event_finish_id, webRequest); | 829 proxy_->dispatchForeignFetchEvent(response_id, event_finish_id, webRequest); |
| 830 } else { | 830 } else { |
| 831 proxy_->dispatchFetchEvent(response_id, event_finish_id, webRequest); | 831 proxy_->dispatchFetchEvent(response_id, event_finish_id, webRequest); |
| 832 } | 832 } |
| 833 } | 833 } |
| 834 | 834 |
| 835 void ServiceWorkerContextClient::OnNotificationClickEvent( | 835 void ServiceWorkerContextClient::OnNotificationClickEvent( |
| 836 int request_id, | 836 int request_id, |
| 837 const std::string& notification_id, | 837 const std::string& notification_id, |
| 838 const PlatformNotificationData& notification_data, | 838 const PlatformNotificationData& notification_data, |
| 839 int action_index) { | 839 int action_index, |
| 840 const base::string16& reply) { |
| 840 TRACE_EVENT0("ServiceWorker", | 841 TRACE_EVENT0("ServiceWorker", |
| 841 "ServiceWorkerContextClient::OnNotificationClickEvent"); | 842 "ServiceWorkerContextClient::OnNotificationClickEvent"); |
| 842 proxy_->dispatchNotificationClickEvent( | 843 proxy_->dispatchNotificationClickEvent( |
| 843 request_id, blink::WebString::fromUTF8(notification_id), | 844 request_id, blink::WebString::fromUTF8(notification_id), |
| 844 ToWebNotificationData(notification_data), action_index); | 845 ToWebNotificationData(notification_data), action_index, |
| 846 blink::WebString(reply)); |
| 845 } | 847 } |
| 846 | 848 |
| 847 void ServiceWorkerContextClient::OnNotificationCloseEvent( | 849 void ServiceWorkerContextClient::OnNotificationCloseEvent( |
| 848 int request_id, | 850 int request_id, |
| 849 const std::string& notification_id, | 851 const std::string& notification_id, |
| 850 const PlatformNotificationData& notification_data) { | 852 const PlatformNotificationData& notification_data) { |
| 851 TRACE_EVENT0("ServiceWorker", | 853 TRACE_EVENT0("ServiceWorker", |
| 852 "ServiceWorkerContextClient::OnNotificationCloseEvent"); | 854 "ServiceWorkerContextClient::OnNotificationCloseEvent"); |
| 853 proxy_->dispatchNotificationCloseEvent( | 855 proxy_->dispatchNotificationCloseEvent( |
| 854 request_id, blink::WebString::fromUTF8(notification_id), | 856 request_id, blink::WebString::fromUTF8(notification_id), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 base::WeakPtr<ServiceWorkerContextClient> | 1058 base::WeakPtr<ServiceWorkerContextClient> |
| 1057 ServiceWorkerContextClient::GetWeakPtr() { | 1059 ServiceWorkerContextClient::GetWeakPtr() { |
| 1058 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1060 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1059 DCHECK(context_); | 1061 DCHECK(context_); |
| 1060 return context_->weak_factory.GetWeakPtr(); | 1062 return context_->weak_factory.GetWeakPtr(); |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 } // namespace content | 1065 } // namespace content |
| OLD | NEW |