| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ServiceWorkerHeaderMap headers; | 82 ServiceWorkerHeaderMap headers; |
| 83 GetServiceWorkerHeaderMapFromWebResponse(web_response, &headers); | 83 GetServiceWorkerHeaderMapFromWebResponse(web_response, &headers); |
| 84 // We don't support streaming for cache. | 84 // We don't support streaming for cache. |
| 85 DCHECK(web_response.streamURL().isEmpty()); | 85 DCHECK(web_response.streamURL().isEmpty()); |
| 86 return ServiceWorkerResponse( | 86 return ServiceWorkerResponse( |
| 87 web_response.url(), web_response.status(), | 87 web_response.url(), web_response.status(), |
| 88 base::UTF16ToASCII(base::StringPiece16(web_response.statusText())), | 88 base::UTF16ToASCII(base::StringPiece16(web_response.statusText())), |
| 89 web_response.responseType(), headers, | 89 web_response.responseType(), headers, |
| 90 base::UTF16ToASCII(base::StringPiece16(web_response.blobUUID())), | 90 base::UTF16ToASCII(base::StringPiece16(web_response.blobUUID())), |
| 91 web_response.blobSize(), web_response.streamURL(), | 91 web_response.blobSize(), web_response.streamURL(), |
| 92 blink::WebServiceWorkerResponseErrorUnknown); | 92 blink::WebServiceWorkerResponseErrorUnknown, |
| 93 base::Time::FromInternalValue(web_response.responseTime())); |
| 93 } | 94 } |
| 94 | 95 |
| 95 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams( | 96 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams( |
| 96 const blink::WebServiceWorkerCache::QueryParams& web_query_params) { | 97 const blink::WebServiceWorkerCache::QueryParams& web_query_params) { |
| 97 CacheStorageCacheQueryParams query_params; | 98 CacheStorageCacheQueryParams query_params; |
| 98 query_params.ignore_search = web_query_params.ignoreSearch; | 99 query_params.ignore_search = web_query_params.ignoreSearch; |
| 99 query_params.ignore_method = web_query_params.ignoreMethod; | 100 query_params.ignore_method = web_query_params.ignoreMethod; |
| 100 query_params.ignore_vary = web_query_params.ignoreVary; | 101 query_params.ignore_vary = web_query_params.ignoreVary; |
| 101 query_params.cache_name = web_query_params.cacheName; | 102 query_params.cache_name = web_query_params.cacheName; |
| 102 return query_params; | 103 return query_params; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 Send(new CacheStorageHostMsg_CacheClosed(cache_id)); | 640 Send(new CacheStorageHostMsg_CacheClosed(cache_id)); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void CacheStorageDispatcher::PopulateWebResponseFromResponse( | 643 void CacheStorageDispatcher::PopulateWebResponseFromResponse( |
| 643 const ServiceWorkerResponse& response, | 644 const ServiceWorkerResponse& response, |
| 644 blink::WebServiceWorkerResponse* web_response) { | 645 blink::WebServiceWorkerResponse* web_response) { |
| 645 web_response->setURL(response.url); | 646 web_response->setURL(response.url); |
| 646 web_response->setStatus(response.status_code); | 647 web_response->setStatus(response.status_code); |
| 647 web_response->setStatusText(base::ASCIIToUTF16(response.status_text)); | 648 web_response->setStatusText(base::ASCIIToUTF16(response.status_text)); |
| 648 web_response->setResponseType(response.response_type); | 649 web_response->setResponseType(response.response_type); |
| 650 web_response->setResponseTime(response.response_time.ToInternalValue()); |
| 649 | 651 |
| 650 for (const auto& i : response.headers) { | 652 for (const auto& i : response.headers) { |
| 651 web_response->setHeader(base::ASCIIToUTF16(i.first), | 653 web_response->setHeader(base::ASCIIToUTF16(i.first), |
| 652 base::ASCIIToUTF16(i.second)); | 654 base::ASCIIToUTF16(i.second)); |
| 653 } | 655 } |
| 654 | 656 |
| 655 if (!response.blob_uuid.empty()) { | 657 if (!response.blob_uuid.empty()) { |
| 656 web_response->setBlob(blink::WebString::fromUTF8(response.blob_uuid), | 658 web_response->setBlob(blink::WebString::fromUTF8(response.blob_uuid), |
| 657 response.blob_size); | 659 response.blob_size); |
| 658 // Let the host know that it can release its reference to the blob. | 660 // Let the host know that it can release its reference to the blob. |
| 659 Send(new CacheStorageHostMsg_BlobDataHandled(response.blob_uuid)); | 661 Send(new CacheStorageHostMsg_BlobDataHandled(response.blob_uuid)); |
| 660 } | 662 } |
| 661 } | 663 } |
| 662 | 664 |
| 663 blink::WebVector<blink::WebServiceWorkerResponse> | 665 blink::WebVector<blink::WebServiceWorkerResponse> |
| 664 CacheStorageDispatcher::WebResponsesFromResponses( | 666 CacheStorageDispatcher::WebResponsesFromResponses( |
| 665 const std::vector<ServiceWorkerResponse>& responses) { | 667 const std::vector<ServiceWorkerResponse>& responses) { |
| 666 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( | 668 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( |
| 667 responses.size()); | 669 responses.size()); |
| 668 for (size_t i = 0; i < responses.size(); ++i) | 670 for (size_t i = 0; i < responses.size(); ++i) |
| 669 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); | 671 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); |
| 670 return web_responses; | 672 return web_responses; |
| 671 } | 673 } |
| 672 | 674 |
| 673 } // namespace content | 675 } // namespace content |
| OLD | NEW |