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

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

Issue 2813243002: network service: pass PlzNavigate resulting data via mojo data pipe (Closed)
Patch Set: fix+comment Created 3 years, 8 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
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | content/common/content_param_traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 (url.has_username() || url.has_password())) { 595 (url.has_username() || url.has_password())) {
596 resource_request->do_not_prompt_for_login = true; 596 resource_request->do_not_prompt_for_login = true;
597 } 597 }
598 resource_request->report_raw_headers = request.ReportRawHeaders(); 598 resource_request->report_raw_headers = request.ReportRawHeaders();
599 resource_request->previews_state = 599 resource_request->previews_state =
600 static_cast<PreviewsState>(request.GetPreviewsState()); 600 static_cast<PreviewsState>(request.GetPreviewsState());
601 601
602 // PlzNavigate: during navigation, the renderer should request a stream which 602 // PlzNavigate: during navigation, the renderer should request a stream which
603 // contains the body of the response. The network request has already been 603 // contains the body of the response. The network request has already been
604 // made by the browser. 604 // made by the browser.
605 mojo::ScopedDataPipeConsumerHandle consumer_handle;
605 if (stream_override_.get()) { 606 if (stream_override_.get()) {
606 CHECK(IsBrowserSideNavigationEnabled()); 607 CHECK(IsBrowserSideNavigationEnabled());
607 DCHECK(!sync_load_response); 608 DCHECK(!sync_load_response);
608 DCHECK_NE(WebURLRequest::kFrameTypeNone, request.GetFrameType()); 609 DCHECK_NE(WebURLRequest::kFrameTypeNone, request.GetFrameType());
609 resource_request->resource_body_stream_url = stream_override_->stream_url; 610 if (stream_override_->consumer_handle.is_valid()) {
611 consumer_handle = std::move(stream_override_->consumer_handle);
612 } else {
613 resource_request->resource_body_stream_url = stream_override_->stream_url;
614 }
610 } 615 }
611 616
612 // PlzNavigate: Invalid renderer main resource requests are rejected by the 617 // PlzNavigate: Invalid renderer main resource requests are rejected by the
613 // browser. This should not happen. 618 // browser. This should not happen.
614 // TODO(arthursonzogni): Remove this when the root cause for 619 // TODO(arthursonzogni): Remove this when the root cause for
615 // https://crbug.com/705508 is found. 620 // https://crbug.com/705508 is found.
616 if (IsBrowserSideNavigationEnabled() && 621 if (IsBrowserSideNavigationEnabled() &&
617 IsResourceTypeFrame(resource_request->resource_type) && 622 IsResourceTypeFrame(resource_request->resource_type) &&
618 !resource_request->resource_body_stream_url.SchemeIs(url::kBlobScheme)) { 623 !resource_request->resource_body_stream_url.SchemeIs(url::kBlobScheme)) {
619 base::debug::DumpWithoutCrashing(); 624 base::debug::DumpWithoutCrashing();
(...skipping 14 matching lines...) Expand all
634 request.GetLoadingIPCType(), url_loader_factory_); 639 request.GetLoadingIPCType(), url_loader_factory_);
635 return; 640 return;
636 } 641 }
637 642
638 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, 643 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this,
639 TRACE_EVENT_FLAG_FLOW_OUT); 644 TRACE_EVENT_FLAG_FLOW_OUT);
640 request_id_ = resource_dispatcher_->StartAsync( 645 request_id_ = resource_dispatcher_->StartAsync(
641 std::move(resource_request), request.RequestorID(), task_runner_, 646 std::move(resource_request), request.RequestorID(), task_runner_,
642 extra_data->frame_origin(), 647 extra_data->frame_origin(),
643 base::MakeUnique<WebURLLoaderImpl::RequestPeerImpl>(this), 648 base::MakeUnique<WebURLLoaderImpl::RequestPeerImpl>(this),
644 request.GetLoadingIPCType(), url_loader_factory_); 649 request.GetLoadingIPCType(), url_loader_factory_,
650 std::move(consumer_handle));
645 651
646 if (defers_loading_ != NOT_DEFERRING) 652 if (defers_loading_ != NOT_DEFERRING)
647 resource_dispatcher_->SetDefersLoading(request_id_, true); 653 resource_dispatcher_->SetDefersLoading(request_id_, true);
648 } 654 }
649 655
650 void WebURLLoaderImpl::Context::SetTaskRunner( 656 void WebURLLoaderImpl::Context::SetTaskRunner(
651 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 657 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
652 task_runner_ = task_runner; 658 task_runner_ = task_runner;
653 } 659 }
654 660
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 client_->DidDownloadData(len, encoded_data_length); 807 client_->DidDownloadData(len, encoded_data_length);
802 } 808 }
803 809
804 void WebURLLoaderImpl::Context::OnReceivedData( 810 void WebURLLoaderImpl::Context::OnReceivedData(
805 std::unique_ptr<ReceivedData> data) { 811 std::unique_ptr<ReceivedData> data) {
806 const char* payload = data->payload(); 812 const char* payload = data->payload();
807 int data_length = data->length(); 813 int data_length = data->length();
808 if (!client_) 814 if (!client_)
809 return; 815 return;
810 816
817 if (stream_override_.get()) {
818 // Since ResourceDispatcher::ContinueForNavigation called OnComplete
jam 2017/04/12 20:49:17 nit: i would put this inside the next if statement
scottmg 2017/04/12 20:51:38 Should be if (a&&b) anyway, fixed.
819 // immediately, it didn't have the size of the resource immediately. So as
820 // data is read off the data pipe, keep track of how much we're reading.
821 if (stream_override_->stream_url.is_empty()) {
822 stream_override_->total_transferred += data_length;
823 }
824 }
825
811 TRACE_EVENT_WITH_FLOW0( 826 TRACE_EVENT_WITH_FLOW0(
812 "loading", "WebURLLoaderImpl::Context::OnReceivedData", 827 "loading", "WebURLLoaderImpl::Context::OnReceivedData",
813 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); 828 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT);
814 829
815 if (ftp_listing_delegate_) { 830 if (ftp_listing_delegate_) {
816 // The FTP listing delegate will make the appropriate calls to 831 // The FTP listing delegate will make the appropriate calls to
817 // client_->didReceiveData and client_->didReceiveResponse. 832 // client_->didReceiveData and client_->didReceiveResponse.
818 ftp_listing_delegate_->OnReceivedData(payload, data_length); 833 ftp_listing_delegate_->OnReceivedData(payload, data_length);
819 } else { 834 } else {
820 // We dispatch the data even when |useStreamOnResponse()| is set, in order 835 // We dispatch the data even when |useStreamOnResponse()| is set, in order
(...skipping 22 matching lines...) Expand all
843 client_->DidReceiveCachedMetadata(data, len); 858 client_->DidReceiveCachedMetadata(data, len);
844 } 859 }
845 860
846 void WebURLLoaderImpl::Context::OnCompletedRequest( 861 void WebURLLoaderImpl::Context::OnCompletedRequest(
847 int error_code, 862 int error_code,
848 bool was_ignored_by_handler, 863 bool was_ignored_by_handler,
849 bool stale_copy_in_cache, 864 bool stale_copy_in_cache,
850 const base::TimeTicks& completion_time, 865 const base::TimeTicks& completion_time,
851 int64_t total_transfer_size, 866 int64_t total_transfer_size,
852 int64_t encoded_body_size) { 867 int64_t encoded_body_size) {
868 if (stream_override_.get()) {
869 if (stream_override_->stream_url.is_empty()) {
870 // TODO(kinuko|scottmg|jam): This is wrong. https://crbug.com/598073.
jam 2017/04/12 20:49:17 nit: 598073 is for network service, while this cod
scottmg 2017/04/12 20:51:38 Put it on the data pipe one, 705744.
871 total_transfer_size = stream_override_->total_transferred;
872 encoded_body_size = stream_override_->total_transferred;
873 }
874 }
875
853 if (ftp_listing_delegate_) { 876 if (ftp_listing_delegate_) {
854 ftp_listing_delegate_->OnCompletedRequest(); 877 ftp_listing_delegate_->OnCompletedRequest();
855 ftp_listing_delegate_.reset(NULL); 878 ftp_listing_delegate_.reset(NULL);
856 } 879 }
857 880
858 if (body_stream_writer_ && error_code != net::OK) 881 if (body_stream_writer_ && error_code != net::OK)
859 body_stream_writer_->Fail(); 882 body_stream_writer_->Fail();
860 body_stream_writer_.reset(); 883 body_stream_writer_.reset();
861 884
862 if (client_) { 885 if (client_) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 int intra_priority_value) { 1280 int intra_priority_value) {
1258 context_->DidChangePriority(new_priority, intra_priority_value); 1281 context_->DidChangePriority(new_priority, intra_priority_value);
1259 } 1282 }
1260 1283
1261 void WebURLLoaderImpl::SetLoadingTaskRunner( 1284 void WebURLLoaderImpl::SetLoadingTaskRunner(
1262 base::SingleThreadTaskRunner* loading_task_runner) { 1285 base::SingleThreadTaskRunner* loading_task_runner) {
1263 context_->SetTaskRunner(loading_task_runner); 1286 context_->SetTaskRunner(loading_task_runner);
1264 } 1287 }
1265 1288
1266 } // namespace content 1289 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | content/common/content_param_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698