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

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

Issue 970693003: ServiceWorker: plumbing for ClientQueryOptions (2/2, chromium) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase build fix... Created 5 years, 9 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
« no previous file with comments | « content/renderer/service_worker/service_worker_script_context.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_script_context.h" 5 #include "content/renderer/service_worker/service_worker_script_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/child/notifications/notification_data_conversions.h" 10 #include "content/child/notifications/notification_data_conversions.h"
11 #include "content/child/service_worker/web_service_worker_registration_impl.h" 11 #include "content/child/service_worker/web_service_worker_registration_impl.h"
12 #include "content/child/thread_safe_sender.h" 12 #include "content/child/thread_safe_sender.h"
13 #include "content/child/webmessageportchannel_impl.h" 13 #include "content/child/webmessageportchannel_impl.h"
14 #include "content/common/message_port_messages.h" 14 #include "content/common/message_port_messages.h"
15 #include "content/common/service_worker/service_worker_messages.h" 15 #include "content/common/service_worker/service_worker_messages.h"
16 #include "content/public/common/referrer.h" 16 #include "content/public/common/referrer.h"
17 #include "content/renderer/service_worker/embedded_worker_context_client.h" 17 #include "content/renderer/service_worker/embedded_worker_context_client.h"
18 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
19 #include "third_party/WebKit/public/platform/WebCrossOriginServiceWorkerClient.h " 19 #include "third_party/WebKit/public/platform/WebCrossOriginServiceWorkerClient.h "
20 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" 20 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
21 #include "third_party/WebKit/public/platform/WebServiceWorkerClientQueryOptions. h"
21 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h" 22 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h"
22 #include "third_party/WebKit/public/platform/WebString.h" 23 #include "third_party/WebKit/public/platform/WebString.h"
23 #include "third_party/WebKit/public/platform/WebURL.h" 24 #include "third_party/WebKit/public/platform/WebURL.h"
24 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h" 25 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h"
25 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" 26 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h"
26 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" 27 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h"
27 28
28 namespace content { 29 namespace content {
29 30
30 namespace { 31 namespace {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ToWebServiceWorkerClientInfo(const ServiceWorkerClientInfo& client_info) { 79 ToWebServiceWorkerClientInfo(const ServiceWorkerClientInfo& client_info) {
79 DCHECK(client_info.IsValid()); 80 DCHECK(client_info.IsValid());
80 81
81 blink::WebServiceWorkerClientInfo web_client_info; 82 blink::WebServiceWorkerClientInfo web_client_info;
82 83
83 web_client_info.clientID = client_info.client_id; 84 web_client_info.clientID = client_info.client_id;
84 web_client_info.pageVisibilityState = client_info.page_visibility_state; 85 web_client_info.pageVisibilityState = client_info.page_visibility_state;
85 web_client_info.isFocused = client_info.is_focused; 86 web_client_info.isFocused = client_info.is_focused;
86 web_client_info.url = client_info.url; 87 web_client_info.url = client_info.url;
87 web_client_info.frameType = GetBlinkFrameType(client_info.frame_type); 88 web_client_info.frameType = GetBlinkFrameType(client_info.frame_type);
89 web_client_info.clientType = client_info.client_type;
88 90
89 return web_client_info; 91 return web_client_info;
90 } 92 }
91 93
92 } // namespace 94 } // namespace
93 95
94 ServiceWorkerScriptContext::ServiceWorkerScriptContext( 96 ServiceWorkerScriptContext::ServiceWorkerScriptContext(
95 EmbeddedWorkerContextClient* embedded_context, 97 EmbeddedWorkerContextClient* embedded_context,
96 blink::WebServiceWorkerContextProxy* proxy) 98 blink::WebServiceWorkerContextProxy* proxy)
97 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), 99 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)),
(...skipping 13 matching lines...) Expand all
111 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent) 113 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent)
112 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent, 114 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_NotificationClickEvent,
113 OnNotificationClickEvent) 115 OnNotificationClickEvent)
114 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent) 116 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEvent)
115 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GeofencingEvent, OnGeofencingEvent) 117 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GeofencingEvent, OnGeofencingEvent)
116 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CrossOriginConnectEvent, 118 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CrossOriginConnectEvent,
117 OnCrossOriginConnectEvent) 119 OnCrossOriginConnectEvent)
118 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage) 120 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage)
119 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CrossOriginMessageToWorker, 121 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CrossOriginMessageToWorker,
120 OnCrossOriginMessageToWorker) 122 OnCrossOriginMessageToWorker)
121 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments, 123 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClients,
122 OnDidGetClientDocuments) 124 OnDidGetClients)
123 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse, 125 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowResponse,
124 OnOpenWindowResponse) 126 OnOpenWindowResponse)
125 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowError, 127 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_OpenWindowError,
126 OnOpenWindowError) 128 OnOpenWindowError)
127 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse, 129 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FocusClientResponse,
128 OnFocusClientResponse) 130 OnFocusClientResponse)
129 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting) 131 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidSkipWaiting, OnDidSkipWaiting)
130 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients) 132 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidClaimClients, OnDidClaimClients)
131 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError) 133 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ClaimClientsError, OnClaimClientsError)
132 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing); 134 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Ping, OnPing);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 GetRoutingID(), request_id)); 216 GetRoutingID(), request_id));
215 } 217 }
216 218
217 void ServiceWorkerScriptContext::DidHandleCrossOriginConnectEvent( 219 void ServiceWorkerScriptContext::DidHandleCrossOriginConnectEvent(
218 int request_id, 220 int request_id,
219 bool accept_connection) { 221 bool accept_connection) {
220 Send(new ServiceWorkerHostMsg_CrossOriginConnectEventFinished( 222 Send(new ServiceWorkerHostMsg_CrossOriginConnectEventFinished(
221 GetRoutingID(), request_id, accept_connection)); 223 GetRoutingID(), request_id, accept_connection));
222 } 224 }
223 225
224 void ServiceWorkerScriptContext::GetClientDocuments( 226 void ServiceWorkerScriptContext::GetClients(
227 const blink::WebServiceWorkerClientQueryOptions& weboptions,
225 blink::WebServiceWorkerClientsCallbacks* callbacks) { 228 blink::WebServiceWorkerClientsCallbacks* callbacks) {
226 DCHECK(callbacks); 229 DCHECK(callbacks);
227 int request_id = pending_clients_callbacks_.Add(callbacks); 230 int request_id = pending_clients_callbacks_.Add(callbacks);
228 Send(new ServiceWorkerHostMsg_GetClientDocuments( 231 ServiceWorkerClientQueryOptions options;
229 GetRoutingID(), request_id)); 232 options.client_type = weboptions.clientType;
233 options.include_uncontrolled = weboptions.includeUncontrolled;
234 Send(new ServiceWorkerHostMsg_GetClients(
235 GetRoutingID(), request_id, options));
230 } 236 }
231 237
232 void ServiceWorkerScriptContext::OpenWindow( 238 void ServiceWorkerScriptContext::OpenWindow(
233 const GURL& url, blink::WebServiceWorkerClientCallbacks* callbacks) { 239 const GURL& url, blink::WebServiceWorkerClientCallbacks* callbacks) {
234 DCHECK(callbacks); 240 DCHECK(callbacks);
235 int request_id = pending_client_callbacks_.Add(callbacks); 241 int request_id = pending_client_callbacks_.Add(callbacks);
236 Send(new ServiceWorkerHostMsg_OpenWindow(GetRoutingID(), request_id, url)); 242 Send(new ServiceWorkerHostMsg_OpenWindow(GetRoutingID(), request_id, url));
237 } 243 }
238 244
239 void ServiceWorkerScriptContext::SetCachedMetadata(const GURL& url, 245 void ServiceWorkerScriptContext::SetCachedMetadata(const GURL& url,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 sent_message_ports, new_routing_ids, 443 sent_message_ports, new_routing_ids,
438 embedded_context_->main_thread_task_runner()); 444 embedded_context_->main_thread_task_runner());
439 445
440 blink::WebCrossOriginServiceWorkerClient web_client; 446 blink::WebCrossOriginServiceWorkerClient web_client;
441 web_client.origin = client.origin; 447 web_client.origin = client.origin;
442 web_client.targetURL = client.target_url; 448 web_client.targetURL = client.target_url;
443 web_client.clientID = client.message_port_id; 449 web_client.clientID = client.message_port_id;
444 proxy_->dispatchCrossOriginMessageEvent(web_client, message, ports); 450 proxy_->dispatchCrossOriginMessageEvent(web_client, message, ports);
445 } 451 }
446 452
447 void ServiceWorkerScriptContext::OnDidGetClientDocuments( 453 void ServiceWorkerScriptContext::OnDidGetClients(
448 int request_id, const std::vector<ServiceWorkerClientInfo>& clients) { 454 int request_id, const std::vector<ServiceWorkerClientInfo>& clients) {
449 TRACE_EVENT0("ServiceWorker", 455 TRACE_EVENT0("ServiceWorker",
450 "ServiceWorkerScriptContext::OnDidGetClientDocuments"); 456 "ServiceWorkerScriptContext::OnDidGetClients");
451 blink::WebServiceWorkerClientsCallbacks* callbacks = 457 blink::WebServiceWorkerClientsCallbacks* callbacks =
452 pending_clients_callbacks_.Lookup(request_id); 458 pending_clients_callbacks_.Lookup(request_id);
453 if (!callbacks) { 459 if (!callbacks) {
454 NOTREACHED() << "Got stray response: " << request_id; 460 NOTREACHED() << "Got stray response: " << request_id;
455 return; 461 return;
456 } 462 }
457 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( 463 scoped_ptr<blink::WebServiceWorkerClientsInfo> info(
458 new blink::WebServiceWorkerClientsInfo); 464 new blink::WebServiceWorkerClientsInfo);
459 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients( 465 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients(
460 clients.size()); 466 clients.size());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 new blink::WebServiceWorkerError(error_type, message)); 578 new blink::WebServiceWorkerError(error_type, message));
573 callbacks->onError(error.release()); 579 callbacks->onError(error.release());
574 pending_claim_clients_callbacks_.Remove(request_id); 580 pending_claim_clients_callbacks_.Remove(request_id);
575 } 581 }
576 582
577 void ServiceWorkerScriptContext::OnPing() { 583 void ServiceWorkerScriptContext::OnPing() {
578 Send(new ServiceWorkerHostMsg_Pong(GetRoutingID())); 584 Send(new ServiceWorkerHostMsg_Pong(GetRoutingID()));
579 } 585 }
580 586
581 } // namespace content 587 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_script_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698