Chromium Code Reviews| 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/cache_storage/cache_storage_dispatcher.h" | 5 #include "content/renderer/cache_storage/cache_storage_dispatcher.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
| 16 #include "content/child/thread_safe_sender.h" | 16 #include "content/child/thread_safe_sender.h" |
| 17 #include "content/common/cache_storage/cache_storage_messages.h" | 17 #include "content/common/cache_storage/cache_storage_messages.h" |
| 18 #include "content/common/service_worker/service_worker_client_info.h" | |
| 18 #include "content/public/common/referrer.h" | 19 #include "content/public/common/referrer.h" |
| 20 #include "content/public/common/request_context_frame_type.h" | |
| 19 #include "content/public/renderer/render_thread.h" | 21 #include "content/public/renderer/render_thread.h" |
| 20 #include "content/renderer/service_worker/service_worker_type_util.h" | 22 #include "content/renderer/service_worker/service_worker_type_util.h" |
| 21 #include "third_party/WebKit/public/platform/WebServiceWorkerCache.h" | 23 #include "third_party/WebKit/public/platform/WebServiceWorkerCache.h" |
| 24 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" | |
| 22 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h" | 25 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h" |
| 23 #include "third_party/WebKit/public/platform/WebServiceWorkerResponse.h" | 26 #include "third_party/WebKit/public/platform/WebServiceWorkerResponse.h" |
| 24 | 27 |
| 25 using base::TimeTicks; | 28 using base::TimeTicks; |
| 26 | 29 |
| 27 namespace content { | 30 namespace content { |
| 28 | 31 |
| 29 using blink::WebServiceWorkerCacheStorage; | 32 using blink::WebServiceWorkerCacheStorage; |
| 30 using blink::WebServiceWorkerCacheError; | 33 using blink::WebServiceWorkerCacheError; |
| 31 using blink::WebServiceWorkerRequest; | 34 using blink::WebServiceWorkerRequest; |
| 32 | 35 |
| 33 static base::LazyInstance<base::ThreadLocalPointer<CacheStorageDispatcher>>:: | 36 static base::LazyInstance<base::ThreadLocalPointer<CacheStorageDispatcher>>:: |
| 34 Leaky g_cache_storage_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; | 37 Leaky g_cache_storage_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; |
| 35 | 38 |
| 36 namespace { | 39 namespace { |
| 37 | 40 |
| 38 CacheStorageDispatcher* const kHasBeenDeleted = | 41 CacheStorageDispatcher* const kHasBeenDeleted = |
| 39 reinterpret_cast<CacheStorageDispatcher*>(0x1); | 42 reinterpret_cast<CacheStorageDispatcher*>(0x1); |
| 40 | 43 |
| 44 ServiceWorkerClientInfo ToServiceWorkerClientInfo( | |
|
jsbell
2015/05/06 16:53:43
For consistency with other functions in this class
Paritosh Kumar
2015/05/07 12:03:13
Done. Thanks.
| |
| 45 const blink::WebServiceWorkerClientInfo& web_client_info) { | |
| 46 ServiceWorkerClientInfo client_info; | |
| 47 | |
| 48 client_info.client_uuid = base::UTF16ToUTF8(web_client_info.uuid); | |
| 49 client_info.page_visibility_state = web_client_info.pageVisibilityState; | |
| 50 client_info.is_focused = web_client_info.isFocused; | |
| 51 client_info.url = web_client_info.url; | |
| 52 client_info.frame_type = | |
|
jsbell
2015/05/06 16:53:43
Note for other reviewers:
The static_cast<> is us
falken
2015/05/07 04:13:42
Thanks :)
| |
| 53 static_cast<RequestContextFrameType>(web_client_info.frameType); | |
| 54 client_info.client_type = web_client_info.clientType; | |
| 55 | |
| 56 return client_info; | |
| 57 } | |
| 58 | |
| 41 ServiceWorkerFetchRequest FetchRequestFromWebRequest( | 59 ServiceWorkerFetchRequest FetchRequestFromWebRequest( |
| 42 const blink::WebServiceWorkerRequest& web_request) { | 60 const blink::WebServiceWorkerRequest& web_request) { |
| 43 ServiceWorkerHeaderMap headers; | 61 ServiceWorkerHeaderMap headers; |
| 44 GetServiceWorkerHeaderMapFromWebRequest(web_request, &headers); | 62 GetServiceWorkerHeaderMapFromWebRequest(web_request, &headers); |
| 45 | 63 |
| 46 return ServiceWorkerFetchRequest( | 64 return ServiceWorkerFetchRequest( |
| 47 web_request.url(), base::UTF16ToASCII(web_request.method()), headers, | 65 web_request.url(), base::UTF16ToASCII(web_request.method()), headers, |
| 48 Referrer(web_request.referrerUrl(), web_request.referrerPolicy()), | 66 Referrer(web_request.referrerUrl(), web_request.referrerPolicy()), |
| 49 web_request.isReload()); | 67 web_request.isReload(), ToServiceWorkerClientInfo(web_request.client())); |
| 50 } | 68 } |
| 51 | 69 |
| 52 void PopulateWebRequestFromFetchRequest( | 70 void PopulateWebRequestFromFetchRequest( |
| 53 const ServiceWorkerFetchRequest& request, | 71 const ServiceWorkerFetchRequest& request, |
| 54 blink::WebServiceWorkerRequest* web_request) { | 72 blink::WebServiceWorkerRequest* web_request) { |
| 55 web_request->setURL(request.url); | 73 web_request->setURL(request.url); |
| 56 web_request->setMethod(base::ASCIIToUTF16(request.method)); | 74 web_request->setMethod(base::ASCIIToUTF16(request.method)); |
| 57 for (ServiceWorkerHeaderMap::const_iterator i = request.headers.begin(), | 75 for (ServiceWorkerHeaderMap::const_iterator i = request.headers.begin(), |
| 58 end = request.headers.end(); | 76 end = request.headers.end(); |
| 59 i != end; ++i) { | 77 i != end; ++i) { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 CacheStorageDispatcher::WebResponsesFromResponses( | 686 CacheStorageDispatcher::WebResponsesFromResponses( |
| 669 const std::vector<ServiceWorkerResponse>& responses) { | 687 const std::vector<ServiceWorkerResponse>& responses) { |
| 670 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( | 688 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( |
| 671 responses.size()); | 689 responses.size()); |
| 672 for (size_t i = 0; i < responses.size(); ++i) | 690 for (size_t i = 0; i < responses.size(); ++i) |
| 673 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); | 691 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); |
| 674 return web_responses; | 692 return web_responses; |
| 675 } | 693 } |
| 676 | 694 |
| 677 } // namespace content | 695 } // namespace content |
| OLD | NEW |