OLD | NEW |
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 Loading... |
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 | |
90 } // namespace | 75 } // namespace |
91 | 76 |
92 ServiceWorkerScriptContext::ServiceWorkerScriptContext( | 77 ServiceWorkerScriptContext::ServiceWorkerScriptContext( |
93 EmbeddedWorkerContextClient* embedded_context, | 78 EmbeddedWorkerContextClient* embedded_context, |
94 blink::WebServiceWorkerContextProxy* proxy) | 79 blink::WebServiceWorkerContextProxy* proxy) |
95 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), | 80 : cache_storage_dispatcher_(new ServiceWorkerCacheStorageDispatcher(this)), |
96 embedded_context_(embedded_context), | 81 embedded_context_(embedded_context), |
97 proxy_(proxy) { | 82 proxy_(proxy) { |
98 } | 83 } |
99 | 84 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 blink::WebServiceWorkerClientsCallbacks* callbacks = | 413 blink::WebServiceWorkerClientsCallbacks* callbacks = |
429 pending_clients_callbacks_.Lookup(request_id); | 414 pending_clients_callbacks_.Lookup(request_id); |
430 if (!callbacks) { | 415 if (!callbacks) { |
431 NOTREACHED() << "Got stray response: " << request_id; | 416 NOTREACHED() << "Got stray response: " << request_id; |
432 return; | 417 return; |
433 } | 418 } |
434 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( | 419 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( |
435 new blink::WebServiceWorkerClientsInfo); | 420 new blink::WebServiceWorkerClientsInfo); |
436 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients( | 421 blink::WebVector<blink::WebServiceWorkerClientInfo> convertedClients( |
437 clients.size()); | 422 clients.size()); |
438 for (size_t i = 0; i < clients.size(); ++i) | 423 for (size_t i = 0; i < clients.size(); ++i) { |
439 convertedClients[i] = ToWebServiceWorkerClientInfo(clients[i]); | 424 convertedClients[i].clientID = clients[i].client_id; |
| 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 } |
440 info->clients.swap(convertedClients); | 431 info->clients.swap(convertedClients); |
441 callbacks->onSuccess(info.release()); | 432 callbacks->onSuccess(info.release()); |
442 pending_clients_callbacks_.Remove(request_id); | 433 pending_clients_callbacks_.Remove(request_id); |
443 } | 434 } |
444 | 435 |
445 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, | 436 void ServiceWorkerScriptContext::OnFocusClientResponse(int request_id, |
446 bool result) { | 437 bool result) { |
447 TRACE_EVENT0("ServiceWorker", | 438 TRACE_EVENT0("ServiceWorker", |
448 "ServiceWorkerScriptContext::OnFocusClientResponse"); | 439 "ServiceWorkerScriptContext::OnFocusClientResponse"); |
449 blink::WebServiceWorkerClientFocusCallback* callback = | 440 blink::WebServiceWorkerClientFocusCallback* callback = |
(...skipping 13 matching lines...) Expand all Loading... |
463 pending_skip_waiting_callbacks_.Lookup(request_id); | 454 pending_skip_waiting_callbacks_.Lookup(request_id); |
464 if (!callbacks) { | 455 if (!callbacks) { |
465 NOTREACHED() << "Got stray response: " << request_id; | 456 NOTREACHED() << "Got stray response: " << request_id; |
466 return; | 457 return; |
467 } | 458 } |
468 callbacks->onSuccess(); | 459 callbacks->onSuccess(); |
469 pending_skip_waiting_callbacks_.Remove(request_id); | 460 pending_skip_waiting_callbacks_.Remove(request_id); |
470 } | 461 } |
471 | 462 |
472 } // namespace content | 463 } // namespace content |
OLD | NEW |