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

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

Issue 2449933003: Use Associated interfaces for mojo-loading (Closed)
Patch Set: fix Created 4 years, 1 month 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 21 matching lines...) Expand all
32 #include "content/common/navigation_params.h" 32 #include "content/common/navigation_params.h"
33 #include "content/common/resource_messages.h" 33 #include "content/common/resource_messages.h"
34 #include "content/common/resource_request.h" 34 #include "content/common/resource_request.h"
35 #include "content/common/resource_request_completion_status.h" 35 #include "content/common/resource_request_completion_status.h"
36 #include "content/public/child/fixed_received_data.h" 36 #include "content/public/child/fixed_received_data.h"
37 #include "content/public/child/request_peer.h" 37 #include "content/public/child/request_peer.h"
38 #include "content/public/child/resource_dispatcher_delegate.h" 38 #include "content/public/child/resource_dispatcher_delegate.h"
39 #include "content/public/common/content_features.h" 39 #include "content/public/common/content_features.h"
40 #include "content/public/common/resource_response.h" 40 #include "content/public/common/resource_response.h"
41 #include "content/public/common/resource_type.h" 41 #include "content/public/common/resource_type.h"
42 #include "mojo/public/cpp/bindings/binding.h" 42 #include "mojo/public/cpp/bindings/associated_binding.h"
43 #include "mojo/public/cpp/bindings/associated_group.h"
44 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
43 #include "net/base/net_errors.h" 45 #include "net/base/net_errors.h"
44 #include "net/base/request_priority.h" 46 #include "net/base/request_priority.h"
45 #include "net/http/http_response_headers.h" 47 #include "net/http/http_response_headers.h"
46 48
47 namespace content { 49 namespace content {
48 50
49 namespace { 51 namespace {
50 52
51 // Converts |time| from a remote to local TimeTicks, overwriting the original 53 // Converts |time| from a remote to local TimeTicks, overwriting the original
52 // value. 54 // value.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 109
108 void OnComplete(const ResourceRequestCompletionStatus& status) override { 110 void OnComplete(const ResourceRequestCompletionStatus& status) override {
109 if (!body_consumer_) { 111 if (!body_consumer_) {
110 resource_dispatcher_->OnMessageReceived( 112 resource_dispatcher_->OnMessageReceived(
111 ResourceMsg_RequestComplete(request_id_, status)); 113 ResourceMsg_RequestComplete(request_id_, status));
112 return; 114 return;
113 } 115 }
114 body_consumer_->OnComplete(status); 116 body_consumer_->OnComplete(status);
115 } 117 }
116 118
117 mojom::URLLoaderClientPtr CreateInterfacePtrAndBind() { 119 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info,
118 return binding_.CreateInterfacePtrAndBind(); 120 mojo::AssociatedGroup* associated_group) {
121 binding_.Bind(client_ptr_info, associated_group);
119 } 122 }
120 123
121 private: 124 private:
122 mojo::Binding<mojom::URLLoaderClient> binding_; 125 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_;
123 scoped_refptr<URLResponseBodyConsumer> body_consumer_; 126 scoped_refptr<URLResponseBodyConsumer> body_consumer_;
124 const int request_id_; 127 const int request_id_;
125 bool has_received_response_ = false; 128 bool has_received_response_ = false;
126 ResourceDispatcher* const resource_dispatcher_; 129 ResourceDispatcher* const resource_dispatcher_;
127 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 130 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
128 }; 131 };
129 132
130 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { 133 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) {
131 if ((request.referrer_policy == blink::WebReferrerPolicyDefault || 134 if ((request.referrer_policy == blink::WebReferrerPolicyDefault ||
132 request.referrer_policy == 135 request.referrer_policy ==
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 response->encoded_body_length = result.encoded_body_length; 657 response->encoded_body_length = result.encoded_body_length;
655 } 658 }
656 659
657 int ResourceDispatcher::StartAsync( 660 int ResourceDispatcher::StartAsync(
658 std::unique_ptr<ResourceRequest> request, 661 std::unique_ptr<ResourceRequest> request,
659 int routing_id, 662 int routing_id,
660 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, 663 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner,
661 const GURL& frame_origin, 664 const GURL& frame_origin,
662 std::unique_ptr<RequestPeer> peer, 665 std::unique_ptr<RequestPeer> peer,
663 blink::WebURLRequest::LoadingIPCType ipc_type, 666 blink::WebURLRequest::LoadingIPCType ipc_type,
664 mojom::URLLoaderFactory* url_loader_factory) { 667 mojom::URLLoaderFactory* url_loader_factory,
668 mojo::AssociatedGroup* associated_group) {
665 CheckSchemeForReferrerPolicy(*request); 669 CheckSchemeForReferrerPolicy(*request);
666 670
667 // Compute a unique request_id for this renderer process. 671 // Compute a unique request_id for this renderer process.
668 int request_id = MakeRequestID(); 672 int request_id = MakeRequestID();
669 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>( 673 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>(
670 std::move(peer), request->resource_type, request->origin_pid, 674 std::move(peer), request->resource_type, request->origin_pid,
671 frame_origin, request->url, request->download_to_file); 675 frame_origin, request->url, request->download_to_file);
672 676
673 if (resource_scheduling_filter_.get() && loading_task_runner) { 677 if (resource_scheduling_filter_.get() && loading_task_runner) {
674 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, 678 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id,
675 loading_task_runner); 679 loading_task_runner);
676 } 680 }
677 681
678 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { 682 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) {
679 std::unique_ptr<URLLoaderClientImpl> client( 683 std::unique_ptr<URLLoaderClientImpl> client(
680 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_)); 684 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_));
681 mojom::URLLoaderPtr url_loader; 685 mojom::URLLoaderAssociatedPtr url_loader;
686 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info;
687 client->Bind(&client_ptr_info, associated_group);
682 url_loader_factory->CreateLoaderAndStart( 688 url_loader_factory->CreateLoaderAndStart(
683 GetProxy(&url_loader), routing_id, request_id, *request, 689 GetProxy(&url_loader, associated_group), routing_id, request_id,
684 client->CreateInterfacePtrAndBind()); 690 *request, std::move(client_ptr_info));
685 pending_requests_[request_id]->url_loader = std::move(url_loader); 691 pending_requests_[request_id]->url_loader = std::move(url_loader);
686 pending_requests_[request_id]->url_loader_client = std::move(client); 692 pending_requests_[request_id]->url_loader_client = std::move(client);
687 } else { 693 } else {
688 message_sender_->Send( 694 message_sender_->Send(
689 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); 695 new ResourceHostMsg_RequestResource(routing_id, request_id, *request));
690 } 696 }
691 697
692 return request_id; 698 return request_id;
693 } 699 }
694 700
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 delete message; 832 delete message;
827 } 833 }
828 } 834 }
829 835
830 void ResourceDispatcher::SetResourceSchedulingFilter( 836 void ResourceDispatcher::SetResourceSchedulingFilter(
831 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 837 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
832 resource_scheduling_filter_ = resource_scheduling_filter; 838 resource_scheduling_filter_ = resource_scheduling_filter;
833 } 839 }
834 840
835 } // namespace content 841 } // 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