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

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

Issue 871013003: Gather the ServiceWorker client information in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rfh_getvisibilitystate
Patch Set: cleanup Created 5 years, 10 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"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 RequestContextType request_context_type) { 65 RequestContextType request_context_type) {
66 return static_cast<blink::WebURLRequest::RequestContext>( 66 return static_cast<blink::WebURLRequest::RequestContext>(
67 request_context_type); 67 request_context_type);
68 } 68 }
69 69
70 blink::WebURLRequest::FrameType GetBlinkFrameType( 70 blink::WebURLRequest::FrameType GetBlinkFrameType(
71 RequestContextFrameType frame_type) { 71 RequestContextFrameType frame_type) {
72 return static_cast<blink::WebURLRequest::FrameType>(frame_type); 72 return static_cast<blink::WebURLRequest::FrameType>(frame_type);
73 } 73 }
74 74
75 blink::WebServiceWorkerClientInfo
76 ToWebServiceWorkerClientInfo(const ServiceWorkerClientInfo& client_info) {
77 DCHECK(client_info.IsValid());
78
79 blink::WebServiceWorkerClientInfo web_client_info;
80
81 web_client_info.clientID = client_info.client_id;
82 web_client_info.pageVisibilityState = client_info.page_visibility_state;
83 web_client_info.isFocused = client_info.is_focused;
84 web_client_info.url = client_info.url;
85 web_client_info.frameType = GetBlinkFrameType(client_info.frame_type);
86
87 return web_client_info;
88 }
89
75 } // namespace 90 } // namespace
76 91
77 ServiceWorkerScriptContext::ServiceWorkerScriptContext( 92 ServiceWorkerScriptContext::ServiceWorkerScriptContext(
78 EmbeddedWorkerContextClient* embedded_context, 93 EmbeddedWorkerContextClient* embedded_context,
79 blink::WebServiceWorkerContextProxy* proxy) 94 blink::WebServiceWorkerContextProxy* proxy)
80 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), 95 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)),
81 embedded_context_(embedded_context), 96 embedded_context_(embedded_context),
82 proxy_(proxy) { 97 proxy_(proxy) {
83 } 98 }
84 99
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 blink::WebServiceWorkerClientsCallbacks* callbacks = 428 blink::WebServiceWorkerClientsCallbacks* callbacks =
414 pending_clients_callbacks_.Lookup(request_id); 429 pending_clients_callbacks_.Lookup(request_id);
415 if (!callbacks) { 430 if (!callbacks) {
416 NOTREACHED() << "Got stray response: " << request_id; 431 NOTREACHED() << "Got stray response: " << request_id;
417 return; 432 return;
418 } 433 }
419 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( 434 scoped_ptr<blink::WebServiceWorkerClientsInfo> info(
420 new blink::WebServiceWorkerClientsInfo); 435 new blink::WebServiceWorkerClientsInfo);
421 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients( 436 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients(
422 clients.size()); 437 clients.size());
423 for (size_t i = 0; i < clients.size(); ++i) { 438 for (size_t i = 0; i < clients.size(); ++i)
424 convertedClients[i].clientID = clients[i].client_id; 439 convertedClients[i] = ToWebServiceWorkerClientInfo(clients[i]);
425 convertedClients[i].pageVisibilityState = clients[i].page_visibility_state;
426 convertedClients[i].isFocused = clients[i].is_focused;
427 convertedClients[i].url = clients[i].url;
428 convertedClients[i].frameType =
429 static_cast<blink::WebURLRequest::FrameType>(clients[i].frame_type);
430 }
431 info->clients.swap(convertedClients); 440 info->clients.swap(convertedClients);
432 callbacks->onSuccess(info.release()); 441 callbacks->onSuccess(info.release());
433 pending_clients_callbacks_.Remove(request_id); 442 pending_clients_callbacks_.Remove(request_id);
434 } 443 }
435 444
436 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, 445 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id,
437 bool result) { 446 bool result) {
438 TRACE_EVENT0("ServiceWorker", 447 TRACE_EVENT0("ServiceWorker",
439 "ServiceWorkerScriptContext::OnFocusClientResponse"); 448 "ServiceWorkerScriptContext::OnFocusClientResponse");
440 blink::WebServiceWorkerClientFocusCallback* callback = 449 blink::WebServiceWorkerClientFocusCallback* callback =
(...skipping 13 matching lines...) Expand all
454 pending_skip_waiting_callbacks_.Lookup(request_id); 463 pending_skip_waiting_callbacks_.Lookup(request_id);
455 if (!callbacks) { 464 if (!callbacks) {
456 NOTREACHED() << "Got stray response: " << request_id; 465 NOTREACHED() << "Got stray response: " << request_id;
457 return; 466 return;
458 } 467 }
459 callbacks->onSuccess(); 468 callbacks->onSuccess();
460 pending_skip_waiting_callbacks_.Remove(request_id); 469 pending_skip_waiting_callbacks_.Remove(request_id);
461 } 470 }
462 471
463 } // namespace content 472 } // 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