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

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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 104
103 void OnComplete(const ResourceRequestCompletionStatus& status) override { 105 void OnComplete(const ResourceRequestCompletionStatus& status) override {
104 if (!body_consumer_) { 106 if (!body_consumer_) {
105 resource_dispatcher_->OnMessageReceived( 107 resource_dispatcher_->OnMessageReceived(
106 ResourceMsg_RequestComplete(request_id_, status)); 108 ResourceMsg_RequestComplete(request_id_, status));
107 return; 109 return;
108 } 110 }
109 body_consumer_->OnComplete(status); 111 body_consumer_->OnComplete(status);
110 } 112 }
111 113
112 mojom::URLLoaderClientPtr CreateInterfacePtrAndBind() { 114 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info,
113 return binding_.CreateInterfacePtrAndBind(); 115 mojo::AssociatedGroup* associated_group) {
116 binding_.Bind(client_ptr_info, associated_group);
114 } 117 }
115 118
116 private: 119 private:
117 mojo::Binding<mojom::URLLoaderClient> binding_; 120 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_;
118 scoped_refptr<URLResponseBodyConsumer> body_consumer_; 121 scoped_refptr<URLResponseBodyConsumer> body_consumer_;
119 const int request_id_; 122 const int request_id_;
120 ResourceDispatcher* const resource_dispatcher_; 123 ResourceDispatcher* const resource_dispatcher_;
121 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 124 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
122 }; 125 };
123 126
124 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { 127 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) {
125 if ((request.referrer_policy == blink::WebReferrerPolicyDefault || 128 if ((request.referrer_policy == blink::WebReferrerPolicyDefault ||
126 request.referrer_policy == 129 request.referrer_policy ==
127 blink::WebReferrerPolicyNoReferrerWhenDowngrade) && 130 blink::WebReferrerPolicyNoReferrerWhenDowngrade) &&
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 response->encoded_body_length = result.encoded_body_length; 654 response->encoded_body_length = result.encoded_body_length;
652 } 655 }
653 656
654 int ResourceDispatcher::StartAsync( 657 int ResourceDispatcher::StartAsync(
655 std::unique_ptr<ResourceRequest> request, 658 std::unique_ptr<ResourceRequest> request,
656 int routing_id, 659 int routing_id,
657 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, 660 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner,
658 const GURL& frame_origin, 661 const GURL& frame_origin,
659 std::unique_ptr<RequestPeer> peer, 662 std::unique_ptr<RequestPeer> peer,
660 blink::WebURLRequest::LoadingIPCType ipc_type, 663 blink::WebURLRequest::LoadingIPCType ipc_type,
661 mojom::URLLoaderFactory* url_loader_factory) { 664 mojom::URLLoaderFactory* url_loader_factory,
665 mojo::AssociatedGroup* associated_group) {
662 CheckSchemeForReferrerPolicy(*request); 666 CheckSchemeForReferrerPolicy(*request);
663 667
664 // Compute a unique request_id for this renderer process. 668 // Compute a unique request_id for this renderer process.
665 int request_id = MakeRequestID(); 669 int request_id = MakeRequestID();
666 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>( 670 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>(
667 std::move(peer), request->resource_type, request->origin_pid, 671 std::move(peer), request->resource_type, request->origin_pid,
668 frame_origin, request->url, request->download_to_file); 672 frame_origin, request->url, request->download_to_file);
669 673
670 if (resource_scheduling_filter_.get() && loading_task_runner) { 674 if (resource_scheduling_filter_.get() && loading_task_runner) {
671 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, 675 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id,
672 loading_task_runner); 676 loading_task_runner);
673 } 677 }
674 678
675 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { 679 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) {
676 std::unique_ptr<URLLoaderClientImpl> client( 680 std::unique_ptr<URLLoaderClientImpl> client(
677 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_)); 681 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_));
678 mojom::URLLoaderPtr url_loader; 682 mojom::URLLoaderAssociatedPtr url_loader;
683 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info;
684 client->Bind(&client_ptr_info, associated_group);
679 url_loader_factory->CreateLoaderAndStart( 685 url_loader_factory->CreateLoaderAndStart(
680 GetProxy(&url_loader), routing_id, request_id, *request, 686 GetProxy(&url_loader, associated_group), routing_id, request_id,
681 client->CreateInterfacePtrAndBind()); 687 *request, std::move(client_ptr_info));
682 pending_requests_[request_id]->url_loader = std::move(url_loader); 688 pending_requests_[request_id]->url_loader = std::move(url_loader);
683 pending_requests_[request_id]->url_loader_client = std::move(client); 689 pending_requests_[request_id]->url_loader_client = std::move(client);
684 } else { 690 } else {
685 message_sender_->Send( 691 message_sender_->Send(
686 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); 692 new ResourceHostMsg_RequestResource(routing_id, request_id, *request));
687 } 693 }
688 694
689 return request_id; 695 return request_id;
690 } 696 }
691 697
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 delete message; 829 delete message;
824 } 830 }
825 } 831 }
826 832
827 void ResourceDispatcher::SetResourceSchedulingFilter( 833 void ResourceDispatcher::SetResourceSchedulingFilter(
828 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 834 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
829 resource_scheduling_filter_ = resource_scheduling_filter; 835 resource_scheduling_filter_ = resource_scheduling_filter;
830 } 836 }
831 837
832 } // namespace content 838 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698