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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
6 | 6 |
7 #include "content/child/web_url_loader_impl.h" | 7 #include "content/child/web_url_loader_impl.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return false; | 523 return false; |
524 } | 524 } |
525 | 525 |
526 void WebURLLoaderImpl::Context::OnReceivedResponse( | 526 void WebURLLoaderImpl::Context::OnReceivedResponse( |
527 const ResourceResponseInfo& info) { | 527 const ResourceResponseInfo& info) { |
528 if (!client_) | 528 if (!client_) |
529 return; | 529 return; |
530 | 530 |
531 WebURLResponse response; | 531 WebURLResponse response; |
532 response.initialize(); | 532 response.initialize(); |
| 533 // Updates the request url if the response was fetched by a ServiceWorker, |
| 534 // and it was not generated inside the ServiceWorker. |
| 535 if (info.was_fetched_via_service_worker && |
| 536 !info.original_url_via_service_worker.is_empty()) { |
| 537 request_.setURL(info.original_url_via_service_worker); |
| 538 } |
533 PopulateURLResponse(request_.url(), info, &response); | 539 PopulateURLResponse(request_.url(), info, &response); |
534 | 540 |
535 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); | 541 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); |
536 | 542 |
537 if (info.mime_type == "text/vnd.chromium.ftp-dir") { | 543 if (info.mime_type == "text/vnd.chromium.ftp-dir") { |
538 if (show_raw_listing) { | 544 if (show_raw_listing) { |
539 // Set the MIME type to plain text to prevent any active content. | 545 // Set the MIME type to plain text to prevent any active content. |
540 response.setMIMEType("text/plain"); | 546 response.setMIMEType("text/plain"); |
541 } else { | 547 } else { |
542 // We're going to produce a parsed listing in HTML. | 548 // We're going to produce a parsed listing in HTML. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 response->setAppCacheID(info.appcache_id); | 751 response->setAppCacheID(info.appcache_id); |
746 response->setAppCacheManifestURL(info.appcache_manifest_url); | 752 response->setAppCacheManifestURL(info.appcache_manifest_url); |
747 response->setWasCached(!info.load_timing.request_start_time.is_null() && | 753 response->setWasCached(!info.load_timing.request_start_time.is_null() && |
748 info.response_time < info.load_timing.request_start_time); | 754 info.response_time < info.load_timing.request_start_time); |
749 response->setRemoteIPAddress( | 755 response->setRemoteIPAddress( |
750 WebString::fromUTF8(info.socket_address.host())); | 756 WebString::fromUTF8(info.socket_address.host())); |
751 response->setRemotePort(info.socket_address.port()); | 757 response->setRemotePort(info.socket_address.port()); |
752 response->setConnectionID(info.load_timing.socket_log_id); | 758 response->setConnectionID(info.load_timing.socket_log_id); |
753 response->setConnectionReused(info.load_timing.socket_reused); | 759 response->setConnectionReused(info.load_timing.socket_reused); |
754 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe()); | 760 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe()); |
| 761 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker); |
755 WebURLResponseExtraDataImpl* extra_data = | 762 WebURLResponseExtraDataImpl* extra_data = |
756 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); | 763 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); |
757 response->setExtraData(extra_data); | 764 response->setExtraData(extra_data); |
758 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); | 765 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); |
759 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); | 766 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); |
760 extra_data->set_was_alternate_protocol_available( | 767 extra_data->set_was_alternate_protocol_available( |
761 info.was_alternate_protocol_available); | 768 info.was_alternate_protocol_available); |
762 extra_data->set_connection_info(info.connection_info); | 769 extra_data->set_connection_info(info.connection_info); |
763 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); | 770 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); |
764 | 771 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 int intra_priority_value) { | 894 int intra_priority_value) { |
888 context_->DidChangePriority(new_priority, intra_priority_value); | 895 context_->DidChangePriority(new_priority, intra_priority_value); |
889 } | 896 } |
890 | 897 |
891 bool WebURLLoaderImpl::attachThreadedDataReceiver( | 898 bool WebURLLoaderImpl::attachThreadedDataReceiver( |
892 blink::WebThreadedDataReceiver* threaded_data_receiver) { | 899 blink::WebThreadedDataReceiver* threaded_data_receiver) { |
893 return context_->AttachThreadedDataReceiver(threaded_data_receiver); | 900 return context_->AttachThreadedDataReceiver(threaded_data_receiver); |
894 } | 901 } |
895 | 902 |
896 } // namespace content | 903 } // namespace content |
OLD | NEW |