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

Side by Side Diff: content/renderer/cache_storage/cache_storage_dispatcher.cc

Issue 2516353002: Introduce url_list to the Response scheme of CacheStorage. (Closed)
Patch Set: incorporated falken's comment Created 4 years 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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 blink::WebVector<blink::WebServiceWorkerRequest> WebRequestsFromRequests( 73 blink::WebVector<blink::WebServiceWorkerRequest> WebRequestsFromRequests(
74 const std::vector<ServiceWorkerFetchRequest>& requests) { 74 const std::vector<ServiceWorkerFetchRequest>& requests) {
75 blink::WebVector<blink::WebServiceWorkerRequest> web_requests( 75 blink::WebVector<blink::WebServiceWorkerRequest> web_requests(
76 requests.size()); 76 requests.size());
77 for (size_t i = 0; i < requests.size(); ++i) 77 for (size_t i = 0; i < requests.size(); ++i)
78 PopulateWebRequestFromFetchRequest(requests[i], &(web_requests[i])); 78 PopulateWebRequestFromFetchRequest(requests[i], &(web_requests[i]));
79 return web_requests; 79 return web_requests;
80 } 80 }
81 81
82 ServiceWorkerResponse ResponseFromWebResponse(
83 const blink::WebServiceWorkerResponse& web_response) {
84 ServiceWorkerHeaderMap headers;
85 GetServiceWorkerHeaderMapFromWebResponse(web_response, &headers);
86 ServiceWorkerHeaderList cors_exposed_header_names;
87 GetCorsExposedHeaderNamesFromWebResponse(web_response,
88 &cors_exposed_header_names);
89 // We don't support streaming for cache.
90 DCHECK(web_response.streamURL().isEmpty());
91 return ServiceWorkerResponse(
92 web_response.url(), web_response.status(),
93 web_response.statusText().ascii(), web_response.responseType(), headers,
94 web_response.blobUUID().ascii(), web_response.blobSize(),
95 web_response.streamURL(), blink::WebServiceWorkerResponseErrorUnknown,
96 base::Time::FromInternalValue(web_response.responseTime()),
97 !web_response.cacheStorageCacheName().isNull(),
98 web_response.cacheStorageCacheName().utf8(), cors_exposed_header_names);
99 }
100
101 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams( 82 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams(
102 const blink::WebServiceWorkerCache::QueryParams& web_query_params) { 83 const blink::WebServiceWorkerCache::QueryParams& web_query_params) {
103 CacheStorageCacheQueryParams query_params; 84 CacheStorageCacheQueryParams query_params;
104 query_params.ignore_search = web_query_params.ignoreSearch; 85 query_params.ignore_search = web_query_params.ignoreSearch;
105 query_params.ignore_method = web_query_params.ignoreMethod; 86 query_params.ignore_method = web_query_params.ignoreMethod;
106 query_params.ignore_vary = web_query_params.ignoreVary; 87 query_params.ignore_vary = web_query_params.ignoreVary;
107 query_params.cache_name = web_query_params.cacheName; 88 query_params.cache_name = web_query_params.cacheName;
108 return query_params; 89 return query_params;
109 } 90 }
110 91
111 CacheStorageCacheOperationType CacheOperationTypeFromWebCacheOperationType( 92 CacheStorageCacheOperationType CacheOperationTypeFromWebCacheOperationType(
112 blink::WebServiceWorkerCache::OperationType operation_type) { 93 blink::WebServiceWorkerCache::OperationType operation_type) {
113 switch (operation_type) { 94 switch (operation_type) {
114 case blink::WebServiceWorkerCache::OperationTypePut: 95 case blink::WebServiceWorkerCache::OperationTypePut:
115 return CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; 96 return CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
116 case blink::WebServiceWorkerCache::OperationTypeDelete: 97 case blink::WebServiceWorkerCache::OperationTypeDelete:
117 return CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE; 98 return CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE;
118 default: 99 default:
119 return CACHE_STORAGE_CACHE_OPERATION_TYPE_UNDEFINED; 100 return CACHE_STORAGE_CACHE_OPERATION_TYPE_UNDEFINED;
120 } 101 }
121 } 102 }
122 103
123 CacheStorageBatchOperation BatchOperationFromWebBatchOperation( 104 CacheStorageBatchOperation BatchOperationFromWebBatchOperation(
124 const blink::WebServiceWorkerCache::BatchOperation& web_operation) { 105 const blink::WebServiceWorkerCache::BatchOperation& web_operation) {
106 // We don't support streaming for cache.
107 DCHECK(web_operation.response.streamURL().isEmpty());
108
125 CacheStorageBatchOperation operation; 109 CacheStorageBatchOperation operation;
126 operation.operation_type = 110 operation.operation_type =
127 CacheOperationTypeFromWebCacheOperationType(web_operation.operationType); 111 CacheOperationTypeFromWebCacheOperationType(web_operation.operationType);
128 operation.request = FetchRequestFromWebRequest(web_operation.request); 112 operation.request = FetchRequestFromWebRequest(web_operation.request);
129 operation.response = ResponseFromWebResponse(web_operation.response); 113 operation.response =
114 GetServiceWorkerResponseFromWebResponse(web_operation.response);
130 operation.match_params = 115 operation.match_params =
131 QueryParamsFromWebQueryParams(web_operation.matchParams); 116 QueryParamsFromWebQueryParams(web_operation.matchParams);
132 return operation; 117 return operation;
133 } 118 }
134 119
135 template <typename T> 120 template <typename T>
136 void ClearCallbacksMapWithErrors(T* callbacks_map) { 121 void ClearCallbacksMapWithErrors(T* callbacks_map) {
137 typename T::iterator iter(callbacks_map); 122 typename T::iterator iter(callbacks_map);
138 while (!iter.IsAtEnd()) { 123 while (!iter.IsAtEnd()) {
139 iter.GetCurrentValue()->onError(blink::WebServiceWorkerCacheErrorNotFound); 124 iter.GetCurrentValue()->onError(blink::WebServiceWorkerCacheErrorNotFound);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 621 }
637 622
638 void CacheStorageDispatcher::OnWebCacheDestruction(int cache_id) { 623 void CacheStorageDispatcher::OnWebCacheDestruction(int cache_id) {
639 web_caches_.Remove(cache_id); 624 web_caches_.Remove(cache_id);
640 Send(new CacheStorageHostMsg_CacheClosed(cache_id)); 625 Send(new CacheStorageHostMsg_CacheClosed(cache_id));
641 } 626 }
642 627
643 void CacheStorageDispatcher::PopulateWebResponseFromResponse( 628 void CacheStorageDispatcher::PopulateWebResponseFromResponse(
644 const ServiceWorkerResponse& response, 629 const ServiceWorkerResponse& response,
645 blink::WebServiceWorkerResponse* web_response) { 630 blink::WebServiceWorkerResponse* web_response) {
646 web_response->setURL(response.url); 631 blink::WebVector<blink::WebURL> url_list(response.url_list.size());
632 std::transform(response.url_list.begin(), response.url_list.end(),
633 url_list.begin(), [](const GURL& url) { return url; });
634 web_response->setURLList(url_list);
635
647 web_response->setStatus(response.status_code); 636 web_response->setStatus(response.status_code);
648 web_response->setStatusText(WebString::fromASCII(response.status_text)); 637 web_response->setStatusText(WebString::fromASCII(response.status_text));
649 web_response->setResponseType(response.response_type); 638 web_response->setResponseType(response.response_type);
650 web_response->setResponseTime(response.response_time.ToInternalValue()); 639 web_response->setResponseTime(response.response_time.ToInternalValue());
651 web_response->setCacheStorageCacheName( 640 web_response->setCacheStorageCacheName(
652 response.is_in_cache_storage 641 response.is_in_cache_storage
653 ? blink::WebString::fromUTF8(response.cache_storage_cache_name) 642 ? blink::WebString::fromUTF8(response.cache_storage_cache_name)
654 : blink::WebString()); 643 : blink::WebString());
655 blink::WebVector<blink::WebString> headers( 644 blink::WebVector<blink::WebString> headers(
656 response.cors_exposed_header_names.size()); 645 response.cors_exposed_header_names.size());
(...skipping 20 matching lines...) Expand all
677 CacheStorageDispatcher::WebResponsesFromResponses( 666 CacheStorageDispatcher::WebResponsesFromResponses(
678 const std::vector<ServiceWorkerResponse>& responses) { 667 const std::vector<ServiceWorkerResponse>& responses) {
679 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( 668 blink::WebVector<blink::WebServiceWorkerResponse> web_responses(
680 responses.size()); 669 responses.size());
681 for (size_t i = 0; i < responses.size(); ++i) 670 for (size_t i = 0; i < responses.size(); ++i)
682 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); 671 PopulateWebResponseFromResponse(responses[i], &(web_responses[i]));
683 return web_responses; 672 return web_responses;
684 } 673 }
685 674
686 } // namespace content 675 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698