OLD | NEW |
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 83 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
84 : binding_(this), | 84 : binding_(this), |
85 request_id_(request_id), | 85 request_id_(request_id), |
86 resource_dispatcher_(resource_dispatcher), | 86 resource_dispatcher_(resource_dispatcher), |
87 task_runner_(std::move(task_runner)) {} | 87 task_runner_(std::move(task_runner)) {} |
88 ~URLLoaderClientImpl() override { | 88 ~URLLoaderClientImpl() override { |
89 if (body_consumer_) | 89 if (body_consumer_) |
90 body_consumer_->Cancel(); | 90 body_consumer_->Cancel(); |
91 } | 91 } |
92 | 92 |
93 void OnReceiveResponse(const ResourceResponseHead& response_head) override { | 93 void OnReceiveResponse( |
| 94 const ResourceResponseHead& response_head, |
| 95 mojom::DownloadedTempFilePtr downloaded_file) override { |
94 has_received_response_ = true; | 96 has_received_response_ = true; |
95 if (body_consumer_) | 97 if (body_consumer_) |
96 body_consumer_->Start(task_runner_.get()); | 98 body_consumer_->Start(task_runner_.get()); |
| 99 downloaded_file_ = std::move(downloaded_file); |
97 resource_dispatcher_->OnMessageReceived( | 100 resource_dispatcher_->OnMessageReceived( |
98 ResourceMsg_ReceivedResponse(request_id_, response_head)); | 101 ResourceMsg_ReceivedResponse(request_id_, response_head)); |
99 } | 102 } |
100 | 103 |
101 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 104 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
102 const ResourceResponseHead& response_head) override { | 105 const ResourceResponseHead& response_head) override { |
103 DCHECK(!has_received_response_); | 106 DCHECK(!has_received_response_); |
104 DCHECK(!body_consumer_); | 107 DCHECK(!body_consumer_); |
105 resource_dispatcher_->OnMessageReceived(ResourceMsg_ReceivedRedirect( | 108 resource_dispatcher_->OnMessageReceived(ResourceMsg_ReceivedRedirect( |
106 request_id_, redirect_info, response_head)); | 109 request_id_, redirect_info, response_head)); |
(...skipping 23 matching lines...) Expand all Loading... |
130 } | 133 } |
131 | 134 |
132 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info, | 135 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info, |
133 mojo::AssociatedGroup* associated_group) { | 136 mojo::AssociatedGroup* associated_group) { |
134 binding_.Bind(client_ptr_info, associated_group); | 137 binding_.Bind(client_ptr_info, associated_group); |
135 } | 138 } |
136 | 139 |
137 private: | 140 private: |
138 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; | 141 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; |
139 scoped_refptr<URLResponseBodyConsumer> body_consumer_; | 142 scoped_refptr<URLResponseBodyConsumer> body_consumer_; |
| 143 mojom::DownloadedTempFilePtr downloaded_file_; |
140 const int request_id_; | 144 const int request_id_; |
141 bool has_received_response_ = false; | 145 bool has_received_response_ = false; |
142 ResourceDispatcher* const resource_dispatcher_; | 146 ResourceDispatcher* const resource_dispatcher_; |
143 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 147 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
144 }; | 148 }; |
145 | 149 |
146 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { | 150 void CheckSchemeForReferrerPolicy(const ResourceRequest& request) { |
147 if ((request.referrer_policy == blink::WebReferrerPolicyDefault || | 151 if ((request.referrer_policy == blink::WebReferrerPolicyDefault || |
148 request.referrer_policy == | 152 request.referrer_policy == |
149 blink::WebReferrerPolicyNoReferrerWhenDowngrade) && | 153 blink::WebReferrerPolicyNoReferrerWhenDowngrade) && |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 delete message; | 855 delete message; |
852 } | 856 } |
853 } | 857 } |
854 | 858 |
855 void ResourceDispatcher::SetResourceSchedulingFilter( | 859 void ResourceDispatcher::SetResourceSchedulingFilter( |
856 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 860 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
857 resource_scheduling_filter_ = resource_scheduling_filter; | 861 resource_scheduling_filter_ = resource_scheduling_filter; |
858 } | 862 } |
859 | 863 |
860 } // namespace content | 864 } // namespace content |
OLD | NEW |