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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 375513002: [ServiceWorker] Propagates ServiceWorker fetched response's URL and wasFetchedViaServiceWorker flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 6 years, 5 months 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 // 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 return false; 524 return false;
525 } 525 }
526 526
527 void WebURLLoaderImpl::Context::OnReceivedResponse( 527 void WebURLLoaderImpl::Context::OnReceivedResponse(
528 const ResourceResponseInfo& info) { 528 const ResourceResponseInfo& info) {
529 if (!client_) 529 if (!client_)
530 return; 530 return;
531 531
532 WebURLResponse response; 532 WebURLResponse response;
533 response.initialize(); 533 response.initialize();
534 // Updates the request url if the response was fetched via a ServiceWorker,
535 // and it was not generated inside the ServiceWorker.
536 if (info.was_fetched_via_service_worker &&
537 !info.original_url_via_service_worker.is_empty()) {
538 request_.setURL(info.original_url_via_service_worker);
tyoshino (SeeGerritForStatus) 2014/07/09 07:09:01 I guess it's ok to also update request_ like this.
539 }
534 PopulateURLResponse(request_.url(), info, &response); 540 PopulateURLResponse(request_.url(), info, &response);
535 541
536 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); 542 bool show_raw_listing = (GURL(request_.url()).query() == "raw");
537 543
538 if (info.mime_type == "text/vnd.chromium.ftp-dir") { 544 if (info.mime_type == "text/vnd.chromium.ftp-dir") {
539 if (show_raw_listing) { 545 if (show_raw_listing) {
540 // Set the MIME type to plain text to prevent any active content. 546 // Set the MIME type to plain text to prevent any active content.
541 response.setMIMEType("text/plain"); 547 response.setMIMEType("text/plain");
542 } else { 548 } else {
543 // We're going to produce a parsed listing in HTML. 549 // We're going to produce a parsed listing in HTML.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 response->setAppCacheID(info.appcache_id); 752 response->setAppCacheID(info.appcache_id);
747 response->setAppCacheManifestURL(info.appcache_manifest_url); 753 response->setAppCacheManifestURL(info.appcache_manifest_url);
748 response->setWasCached(!info.load_timing.request_start_time.is_null() && 754 response->setWasCached(!info.load_timing.request_start_time.is_null() &&
749 info.response_time < info.load_timing.request_start_time); 755 info.response_time < info.load_timing.request_start_time);
750 response->setRemoteIPAddress( 756 response->setRemoteIPAddress(
751 WebString::fromUTF8(info.socket_address.host())); 757 WebString::fromUTF8(info.socket_address.host()));
752 response->setRemotePort(info.socket_address.port()); 758 response->setRemotePort(info.socket_address.port());
753 response->setConnectionID(info.load_timing.socket_log_id); 759 response->setConnectionID(info.load_timing.socket_log_id);
754 response->setConnectionReused(info.load_timing.socket_reused); 760 response->setConnectionReused(info.load_timing.socket_reused);
755 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe()); 761 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe());
762 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker);
756 WebURLResponseExtraDataImpl* extra_data = 763 WebURLResponseExtraDataImpl* extra_data =
757 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); 764 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol);
758 response->setExtraData(extra_data); 765 response->setExtraData(extra_data);
759 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); 766 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
760 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); 767 extra_data->set_was_npn_negotiated(info.was_npn_negotiated);
761 extra_data->set_was_alternate_protocol_available( 768 extra_data->set_was_alternate_protocol_available(
762 info.was_alternate_protocol_available); 769 info.was_alternate_protocol_available);
763 extra_data->set_connection_info(info.connection_info); 770 extra_data->set_connection_info(info.connection_info);
764 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); 771 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy);
765 772
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 int intra_priority_value) { 895 int intra_priority_value) {
889 context_->DidChangePriority(new_priority, intra_priority_value); 896 context_->DidChangePriority(new_priority, intra_priority_value);
890 } 897 }
891 898
892 bool WebURLLoaderImpl::attachThreadedDataReceiver( 899 bool WebURLLoaderImpl::attachThreadedDataReceiver(
893 blink::WebThreadedDataReceiver* threaded_data_receiver) { 900 blink::WebThreadedDataReceiver* threaded_data_receiver) {
894 return context_->AttachThreadedDataReceiver(threaded_data_receiver); 901 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
895 } 902 }
896 903
897 } // namespace content 904 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698