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/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 Loading... |
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 Loading... |
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 Loading... |
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_ && stream_override_->stream_url.is_empty()) { |
| 818 // Since ResourceDispatcher::ContinueForNavigation called OnComplete |
| 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 stream_override_->total_transferred += data_length; |
| 822 } |
| 823 |
811 TRACE_EVENT_WITH_FLOW0( | 824 TRACE_EVENT_WITH_FLOW0( |
812 "loading", "WebURLLoaderImpl::Context::OnReceivedData", | 825 "loading", "WebURLLoaderImpl::Context::OnReceivedData", |
813 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 826 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
814 | 827 |
815 if (ftp_listing_delegate_) { | 828 if (ftp_listing_delegate_) { |
816 // The FTP listing delegate will make the appropriate calls to | 829 // The FTP listing delegate will make the appropriate calls to |
817 // client_->didReceiveData and client_->didReceiveResponse. | 830 // client_->didReceiveData and client_->didReceiveResponse. |
818 ftp_listing_delegate_->OnReceivedData(payload, data_length); | 831 ftp_listing_delegate_->OnReceivedData(payload, data_length); |
819 } else { | 832 } else { |
820 // We dispatch the data even when |useStreamOnResponse()| is set, in order | 833 // We dispatch the data even when |useStreamOnResponse()| is set, in order |
(...skipping 22 matching lines...) Expand all Loading... |
843 client_->DidReceiveCachedMetadata(data, len); | 856 client_->DidReceiveCachedMetadata(data, len); |
844 } | 857 } |
845 | 858 |
846 void WebURLLoaderImpl::Context::OnCompletedRequest( | 859 void WebURLLoaderImpl::Context::OnCompletedRequest( |
847 int error_code, | 860 int error_code, |
848 bool was_ignored_by_handler, | 861 bool was_ignored_by_handler, |
849 bool stale_copy_in_cache, | 862 bool stale_copy_in_cache, |
850 const base::TimeTicks& completion_time, | 863 const base::TimeTicks& completion_time, |
851 int64_t total_transfer_size, | 864 int64_t total_transfer_size, |
852 int64_t encoded_body_size) { | 865 int64_t encoded_body_size) { |
| 866 if (stream_override_ && stream_override_->stream_url.is_empty()) { |
| 867 // TODO(kinuko|scottmg|jam): This is wrong. https://crbug.com/705744. |
| 868 total_transfer_size = stream_override_->total_transferred; |
| 869 encoded_body_size = stream_override_->total_transferred; |
| 870 } |
| 871 |
853 if (ftp_listing_delegate_) { | 872 if (ftp_listing_delegate_) { |
854 ftp_listing_delegate_->OnCompletedRequest(); | 873 ftp_listing_delegate_->OnCompletedRequest(); |
855 ftp_listing_delegate_.reset(NULL); | 874 ftp_listing_delegate_.reset(NULL); |
856 } | 875 } |
857 | 876 |
858 if (body_stream_writer_ && error_code != net::OK) | 877 if (body_stream_writer_ && error_code != net::OK) |
859 body_stream_writer_->Fail(); | 878 body_stream_writer_->Fail(); |
860 body_stream_writer_.reset(); | 879 body_stream_writer_.reset(); |
861 | 880 |
862 if (client_) { | 881 if (client_) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 int intra_priority_value) { | 1276 int intra_priority_value) { |
1258 context_->DidChangePriority(new_priority, intra_priority_value); | 1277 context_->DidChangePriority(new_priority, intra_priority_value); |
1259 } | 1278 } |
1260 | 1279 |
1261 void WebURLLoaderImpl::SetLoadingTaskRunner( | 1280 void WebURLLoaderImpl::SetLoadingTaskRunner( |
1262 base::SingleThreadTaskRunner* loading_task_runner) { | 1281 base::SingleThreadTaskRunner* loading_task_runner) { |
1263 context_->SetTaskRunner(loading_task_runner); | 1282 context_->SetTaskRunner(loading_task_runner); |
1264 } | 1283 } |
1265 | 1284 |
1266 } // namespace content | 1285 } // namespace content |
OLD | NEW |