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

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

Issue 2813243002: network service: pass PlzNavigate resulting data via mojo data pipe (Closed)
Patch Set: ahem 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/resource_dispatcher.h ('k') | content/child/resource_dispatcher_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/child/resource_dispatcher.h" 7 #include "content/child/resource_dispatcher.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 response->encoded_body_length = result.encoded_body_length; 613 response->encoded_body_length = result.encoded_body_length;
614 } 614 }
615 615
616 int ResourceDispatcher::StartAsync( 616 int ResourceDispatcher::StartAsync(
617 std::unique_ptr<ResourceRequest> request, 617 std::unique_ptr<ResourceRequest> request,
618 int routing_id, 618 int routing_id,
619 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, 619 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner,
620 const url::Origin& frame_origin, 620 const url::Origin& frame_origin,
621 std::unique_ptr<RequestPeer> peer, 621 std::unique_ptr<RequestPeer> peer,
622 blink::WebURLRequest::LoadingIPCType ipc_type, 622 blink::WebURLRequest::LoadingIPCType ipc_type,
623 mojom::URLLoaderFactory* url_loader_factory) { 623 mojom::URLLoaderFactory* url_loader_factory,
624 mojo::ScopedDataPipeConsumerHandle consumer_handle) {
624 CheckSchemeForReferrerPolicy(*request); 625 CheckSchemeForReferrerPolicy(*request);
625 626
626 // Compute a unique request_id for this renderer process. 627 // Compute a unique request_id for this renderer process.
627 int request_id = MakeRequestID(); 628 int request_id = MakeRequestID();
628 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>( 629 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>(
629 std::move(peer), request->resource_type, request->origin_pid, 630 std::move(peer), request->resource_type, request->origin_pid,
630 frame_origin, request->url, request->download_to_file); 631 frame_origin, request->url, request->download_to_file);
631 632
632 if (resource_scheduling_filter_.get() && loading_task_runner) { 633 if (resource_scheduling_filter_.get() && loading_task_runner) {
633 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, 634 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id,
634 loading_task_runner); 635 loading_task_runner);
635 } 636 }
636 637
638 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
639 loading_task_runner ? loading_task_runner : main_thread_task_runner_;
640
641 if (consumer_handle.is_valid()) {
642 pending_requests_[request_id]->url_loader_client =
643 base::MakeUnique<URLLoaderClientImpl>(request_id, this, task_runner);
644
645 task_runner->PostTask(FROM_HERE,
646 base::Bind(&ResourceDispatcher::ContinueForNavigation,
647 weak_factory_.GetWeakPtr(), request_id,
648 base::Passed(std::move(consumer_handle))));
649
650 return request_id;
651 }
652
637 if (ipc_type == blink::WebURLRequest::LoadingIPCType::kMojo) { 653 if (ipc_type == blink::WebURLRequest::LoadingIPCType::kMojo) {
638 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 654 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
639 loading_task_runner ? loading_task_runner : main_thread_task_runner_; 655 loading_task_runner ? loading_task_runner : main_thread_task_runner_;
640 std::unique_ptr<URLLoaderClientImpl> client( 656 std::unique_ptr<URLLoaderClientImpl> client(
641 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); 657 new URLLoaderClientImpl(request_id, this, std::move(task_runner)));
642 mojom::URLLoaderAssociatedPtr url_loader; 658 mojom::URLLoaderAssociatedPtr url_loader;
643 mojom::URLLoaderClientPtr client_ptr; 659 mojom::URLLoaderClientPtr client_ptr;
644 client->Bind(&client_ptr); 660 client->Bind(&client_ptr);
645 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), 661 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader),
646 routing_id, request_id, *request, 662 routing_id, request_id, *request,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 744 }
729 745
730 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() { 746 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() {
731 if (io_timestamp_ == base::TimeTicks()) 747 if (io_timestamp_ == base::TimeTicks())
732 return base::TimeTicks::Now(); 748 return base::TimeTicks::Now();
733 base::TimeTicks result = io_timestamp_; 749 base::TimeTicks result = io_timestamp_;
734 io_timestamp_ = base::TimeTicks(); 750 io_timestamp_ = base::TimeTicks();
735 return result; 751 return result;
736 } 752 }
737 753
754 void ResourceDispatcher::ContinueForNavigation(
755 int request_id,
756 mojo::ScopedDataPipeConsumerHandle consumer_handle) {
757 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
758 if (!request_info)
759 return;
760
761 URLLoaderClientImpl* client_ptr = request_info->url_loader_client.get();
762
763 // Short circuiting call to OnReceivedResponse to immediately start
764 // the request. ResourceResponseHead can be empty here because we
765 // pull the StreamOverride's one in
766 // WebURLLoaderImpl::Context::OnReceivedResponse.
767 client_ptr->OnReceiveResponse(ResourceResponseHead(),
768 mojom::DownloadedTempFilePtr());
769 // Start streaming now.
770 client_ptr->OnStartLoadingResponseBody(std::move(consumer_handle));
771
772 // Call OnComplete now too, as it won't get called on the client.
773 // TODO(kinuko): Fill this properly.
774 ResourceRequestCompletionStatus completion_status;
775 completion_status.error_code = net::OK;
776 completion_status.was_ignored_by_handler = false;
777 completion_status.exists_in_cache = false;
778 completion_status.completion_time = base::TimeTicks::Now();
779 completion_status.encoded_data_length = -1;
780 completion_status.encoded_body_length = -1;
781 client_ptr->OnComplete(completion_status);
782 }
783
738 // static 784 // static
739 bool ResourceDispatcher::IsResourceDispatcherMessage( 785 bool ResourceDispatcher::IsResourceDispatcherMessage(
740 const IPC::Message& message) { 786 const IPC::Message& message) {
741 switch (message.type()) { 787 switch (message.type()) {
742 case ResourceMsg_UploadProgress::ID: 788 case ResourceMsg_UploadProgress::ID:
743 case ResourceMsg_ReceivedResponse::ID: 789 case ResourceMsg_ReceivedResponse::ID:
744 case ResourceMsg_ReceivedCachedMetadata::ID: 790 case ResourceMsg_ReceivedCachedMetadata::ID:
745 case ResourceMsg_ReceivedRedirect::ID: 791 case ResourceMsg_ReceivedRedirect::ID:
746 case ResourceMsg_SetDataBuffer::ID: 792 case ResourceMsg_SetDataBuffer::ID:
747 case ResourceMsg_DataReceived::ID: 793 case ResourceMsg_DataReceived::ID:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 delete message; 834 delete message;
789 } 835 }
790 } 836 }
791 837
792 void ResourceDispatcher::SetResourceSchedulingFilter( 838 void ResourceDispatcher::SetResourceSchedulingFilter(
793 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 839 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
794 resource_scheduling_filter_ = resource_scheduling_filter; 840 resource_scheduling_filter_ = resource_scheduling_filter;
795 } 841 }
796 842
797 } // namespace content 843 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/child/resource_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698