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

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

Issue 2797443005: PlzNavigate data pipe
Patch Set: cleanup 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/web_url_loader_impl.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 (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 std::unique_ptr<URLLoaderClientImpl> client(
643 new URLLoaderClientImpl(request_id, this, task_runner));
644 pending_requests_[request_id]->url_loader_client = std::move(client);
645
646 task_runner->PostTask(FROM_HERE,
647 base::Bind(&ResourceDispatcher::ContinueForNavigation,
648 weak_factory_.GetWeakPtr(), request_id,
649 base::Passed(std::move(consumer_handle))));
650
651 return request_id;
652 }
653
637 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { 654 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) {
638 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
639 loading_task_runner ? loading_task_runner : main_thread_task_runner_;
640 std::unique_ptr<URLLoaderClientImpl> client( 655 std::unique_ptr<URLLoaderClientImpl> client(
641 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); 656 new URLLoaderClientImpl(request_id, this, std::move(task_runner)));
642 mojom::URLLoaderAssociatedPtr url_loader; 657 mojom::URLLoaderAssociatedPtr url_loader;
643 mojom::URLLoaderClientPtr client_ptr; 658 mojom::URLLoaderClientPtr client_ptr;
644 client->Bind(&client_ptr); 659 client->Bind(&client_ptr);
645 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), 660 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader),
646 routing_id, request_id, *request, 661 routing_id, request_id, *request,
647 std::move(client_ptr)); 662 std::move(client_ptr));
648 pending_requests_[request_id]->url_loader = std::move(url_loader); 663 pending_requests_[request_id]->url_loader = std::move(url_loader);
649 pending_requests_[request_id]->url_loader_client = std::move(client); 664 pending_requests_[request_id]->url_loader_client = std::move(client);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 743 }
729 744
730 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() { 745 base::TimeTicks ResourceDispatcher::ConsumeIOTimestamp() {
731 if (io_timestamp_ == base::TimeTicks()) 746 if (io_timestamp_ == base::TimeTicks())
732 return base::TimeTicks::Now(); 747 return base::TimeTicks::Now();
733 base::TimeTicks result = io_timestamp_; 748 base::TimeTicks result = io_timestamp_;
734 io_timestamp_ = base::TimeTicks(); 749 io_timestamp_ = base::TimeTicks();
735 return result; 750 return result;
736 } 751 }
737 752
753 void ResourceDispatcher::ContinueForNavigation(
754 int request_id,
755 mojo::ScopedDataPipeConsumerHandle consumer_handle) {
756 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
757 if (!request_info)
758 return;
759
760 URLLoaderClientImpl* client_ptr = request_info->url_loader_client.get();
761
762 // Short circuiting call to OnReceivedResponse to immediately start
763 // the request. ResourceResponseHead can be empty here because we
764 // pull the StreamOverride's one in
765 // WebURLLoaderImpl::Context::OnReceivedResponse.
766 client_ptr->OnReceiveResponse(ResourceResponseHead(),
767 mojom::DownloadedTempFilePtr());
768 // Start streaming now.
769 client_ptr->OnStartLoadingResponseBody(std::move(consumer_handle));
770
771 // Call OnComplete now too, as it won't get called on the client.
772 // TODO(kinuko): Fill this properly.
773 ResourceRequestCompletionStatus completion_status;
774 completion_status.error_code = net::OK;
775 completion_status.was_ignored_by_handler = false;
776 completion_status.exists_in_cache = false;
777 completion_status.completion_time = base::TimeTicks::Now();
778 completion_status.encoded_data_length = -1;
779 completion_status.encoded_body_length = -1;
780 client_ptr->OnComplete(completion_status);
781 }
782
738 // static 783 // static
739 bool ResourceDispatcher::IsResourceDispatcherMessage( 784 bool ResourceDispatcher::IsResourceDispatcherMessage(
740 const IPC::Message& message) { 785 const IPC::Message& message) {
741 switch (message.type()) { 786 switch (message.type()) {
742 case ResourceMsg_UploadProgress::ID: 787 case ResourceMsg_UploadProgress::ID:
743 case ResourceMsg_ReceivedResponse::ID: 788 case ResourceMsg_ReceivedResponse::ID:
744 case ResourceMsg_ReceivedCachedMetadata::ID: 789 case ResourceMsg_ReceivedCachedMetadata::ID:
745 case ResourceMsg_ReceivedRedirect::ID: 790 case ResourceMsg_ReceivedRedirect::ID:
746 case ResourceMsg_SetDataBuffer::ID: 791 case ResourceMsg_SetDataBuffer::ID:
747 case ResourceMsg_DataReceived::ID: 792 case ResourceMsg_DataReceived::ID:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 delete message; 833 delete message;
789 } 834 }
790 } 835 }
791 836
792 void ResourceDispatcher::SetResourceSchedulingFilter( 837 void ResourceDispatcher::SetResourceSchedulingFilter(
793 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 838 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
794 resource_scheduling_filter_ = resource_scheduling_filter; 839 resource_scheduling_filter_ = resource_scheduling_filter;
795 } 840 }
796 841
797 } // namespace content 842 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/child/web_url_loader_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698