Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2392343002: Plumbing in notification replies: PlatformNotificationService -> SW (Closed)
Patch Set: Send NullableString through IPC, remove settings check from ButtonClickWithReply, add TODO in messa… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
Peter Beverloo 2016/10/12 13:58:31 delete?
awdf 2016/10/12 17:04:01 Done.
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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 const FetchCallback& callback) { 861 const FetchCallback& callback) {
861 blink::WebServiceWorkerRequest webRequest; 862 blink::WebServiceWorkerRequest webRequest;
862 TRACE_EVENT0("ServiceWorker", 863 TRACE_EVENT0("ServiceWorker",
863 "ServiceWorkerContextClient::DispatchFetchEvent"); 864 "ServiceWorkerContextClient::DispatchFetchEvent");
864 int event_finish_id = 865 int event_finish_id =
865 context_->fetch_event_callbacks.Add(new FetchCallback(callback)); 866 context_->fetch_event_callbacks.Add(new FetchCallback(callback));
866 867
867 webRequest.setURL(blink::WebURL(request.url)); 868 webRequest.setURL(blink::WebURL(request.url));
868 webRequest.setMethod(blink::WebString::fromUTF8(request.method)); 869 webRequest.setMethod(blink::WebString::fromUTF8(request.method));
869 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin(); 870 for (ServiceWorkerHeaderMap::const_iterator it = request.headers.begin();
870 it != request.headers.end(); 871 it != request.headers.end(); ++it) {
871 ++it) {
872 webRequest.setHeader(blink::WebString::fromUTF8(it->first), 872 webRequest.setHeader(blink::WebString::fromUTF8(it->first),
873 blink::WebString::fromUTF8(it->second)); 873 blink::WebString::fromUTF8(it->second));
874 } 874 }
875 if (!request.blob_uuid.empty()) { 875 if (!request.blob_uuid.empty()) {
876 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), 876 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid),
877 request.blob_size); 877 request.blob_size);
878 } 878 }
879 webRequest.setReferrer( 879 webRequest.setReferrer(
880 blink::WebString::fromUTF8(request.referrer.url.spec()), 880 blink::WebString::fromUTF8(request.referrer.url.spec()),
881 request.referrer.policy); 881 request.referrer.policy);
(...skipping 11 matching lines...) Expand all
893 proxy_->dispatchForeignFetchEvent(response_id, event_finish_id, webRequest); 893 proxy_->dispatchForeignFetchEvent(response_id, event_finish_id, webRequest);
894 } else { 894 } else {
895 proxy_->dispatchFetchEvent(response_id, event_finish_id, webRequest); 895 proxy_->dispatchFetchEvent(response_id, event_finish_id, webRequest);
896 } 896 }
897 } 897 }
898 898
899 void ServiceWorkerContextClient::OnNotificationClickEvent( 899 void ServiceWorkerContextClient::OnNotificationClickEvent(
900 int request_id, 900 int request_id,
901 const std::string& notification_id, 901 const std::string& notification_id,
902 const PlatformNotificationData& notification_data, 902 const PlatformNotificationData& notification_data,
903 int action_index) { 903 int action_index,
904 const base::NullableString16& reply) {
904 TRACE_EVENT0("ServiceWorker", 905 TRACE_EVENT0("ServiceWorker",
905 "ServiceWorkerContextClient::OnNotificationClickEvent"); 906 "ServiceWorkerContextClient::OnNotificationClickEvent");
906 proxy_->dispatchNotificationClickEvent( 907 proxy_->dispatchNotificationClickEvent(
907 request_id, blink::WebString::fromUTF8(notification_id), 908 request_id, blink::WebString::fromUTF8(notification_id),
908 ToWebNotificationData(notification_data), action_index); 909 ToWebNotificationData(notification_data), action_index,
910 blink::WebString(reply));
909 } 911 }
910 912
911 void ServiceWorkerContextClient::OnNotificationCloseEvent( 913 void ServiceWorkerContextClient::OnNotificationCloseEvent(
912 int request_id, 914 int request_id,
913 const std::string& notification_id, 915 const std::string& notification_id,
914 const PlatformNotificationData& notification_data) { 916 const PlatformNotificationData& notification_data) {
915 TRACE_EVENT0("ServiceWorker", 917 TRACE_EVENT0("ServiceWorker",
916 "ServiceWorkerContextClient::OnNotificationCloseEvent"); 918 "ServiceWorkerContextClient::OnNotificationCloseEvent");
917 proxy_->dispatchNotificationCloseEvent( 919 proxy_->dispatchNotificationCloseEvent(
918 request_id, blink::WebString::fromUTF8(notification_id), 920 request_id, blink::WebString::fromUTF8(notification_id),
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 } 1120 }
1119 1121
1120 base::WeakPtr<ServiceWorkerContextClient> 1122 base::WeakPtr<ServiceWorkerContextClient>
1121 ServiceWorkerContextClient::GetWeakPtr() { 1123 ServiceWorkerContextClient::GetWeakPtr() {
1122 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1124 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1123 DCHECK(context_); 1125 DCHECK(context_);
1124 return context_->weak_factory.GetWeakPtr(); 1126 return context_->weak_factory.GetWeakPtr();
1125 } 1127 }
1126 1128
1127 } // namespace content 1129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698