| 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())); | |
| 94 } | 93 } |
| 95 | 94 |
| 96 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams( | 95 CacheStorageCacheQueryParams QueryParamsFromWebQueryParams( |
| 97 const blink::WebServiceWorkerCache::QueryParams& web_query_params) { | 96 const blink::WebServiceWorkerCache::QueryParams& web_query_params) { |
| 98 CacheStorageCacheQueryParams query_params; | 97 CacheStorageCacheQueryParams query_params; |
| 99 query_params.ignore_search = web_query_params.ignoreSearch; | 98 query_params.ignore_search = web_query_params.ignoreSearch; |
| 100 query_params.ignore_method = web_query_params.ignoreMethod; | 99 query_params.ignore_method = web_query_params.ignoreMethod; |
| 101 query_params.ignore_vary = web_query_params.ignoreVary; | 100 query_params.ignore_vary = web_query_params.ignoreVary; |
| 102 query_params.cache_name = web_query_params.cacheName; | 101 query_params.cache_name = web_query_params.cacheName; |
| 103 return query_params; | 102 return query_params; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 Send(new CacheStorageHostMsg_CacheClosed(cache_id)); | 639 Send(new CacheStorageHostMsg_CacheClosed(cache_id)); |
| 641 } | 640 } |
| 642 | 641 |
| 643 void CacheStorageDispatcher::PopulateWebResponseFromResponse( | 642 void CacheStorageDispatcher::PopulateWebResponseFromResponse( |
| 644 const ServiceWorkerResponse& response, | 643 const ServiceWorkerResponse& response, |
| 645 blink::WebServiceWorkerResponse* web_response) { | 644 blink::WebServiceWorkerResponse* web_response) { |
| 646 web_response->setURL(response.url); | 645 web_response->setURL(response.url); |
| 647 web_response->setStatus(response.status_code); | 646 web_response->setStatus(response.status_code); |
| 648 web_response->setStatusText(base::ASCIIToUTF16(response.status_text)); | 647 web_response->setStatusText(base::ASCIIToUTF16(response.status_text)); |
| 649 web_response->setResponseType(response.response_type); | 648 web_response->setResponseType(response.response_type); |
| 650 web_response->setResponseTime(response.response_time.ToInternalValue()); | |
| 651 | 649 |
| 652 for (const auto& i : response.headers) { | 650 for (const auto& i : response.headers) { |
| 653 web_response->setHeader(base::ASCIIToUTF16(i.first), | 651 web_response->setHeader(base::ASCIIToUTF16(i.first), |
| 654 base::ASCIIToUTF16(i.second)); | 652 base::ASCIIToUTF16(i.second)); |
| 655 } | 653 } |
| 656 | 654 |
| 657 if (!response.blob_uuid.empty()) { | 655 if (!response.blob_uuid.empty()) { |
| 658 web_response->setBlob(blink::WebString::fromUTF8(response.blob_uuid), | 656 web_response->setBlob(blink::WebString::fromUTF8(response.blob_uuid), |
| 659 response.blob_size); | 657 response.blob_size); |
| 660 // Let the host know that it can release its reference to the blob. | 658 // Let the host know that it can release its reference to the blob. |
| 661 Send(new CacheStorageHostMsg_BlobDataHandled(response.blob_uuid)); | 659 Send(new CacheStorageHostMsg_BlobDataHandled(response.blob_uuid)); |
| 662 } | 660 } |
| 663 } | 661 } |
| 664 | 662 |
| 665 blink::WebVector<blink::WebServiceWorkerResponse> | 663 blink::WebVector<blink::WebServiceWorkerResponse> |
| 666 CacheStorageDispatcher::WebResponsesFromResponses( | 664 CacheStorageDispatcher::WebResponsesFromResponses( |
| 667 const std::vector<ServiceWorkerResponse>& responses) { | 665 const std::vector<ServiceWorkerResponse>& responses) { |
| 668 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( | 666 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( |
| 669 responses.size()); | 667 responses.size()); |
| 670 for (size_t i = 0; i < responses.size(); ++i) | 668 for (size_t i = 0; i < responses.size(); ++i) |
| 671 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); | 669 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); |
| 672 return web_responses; | 670 return web_responses; |
| 673 } | 671 } |
| 674 | 672 |
| 675 } // namespace content | 673 } // namespace content |
| OLD | NEW |