OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/child/url_loader_client_impl.h" | 5 #include "content/child/url_loader_client_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "content/child/resource_dispatcher.h" | 9 #include "content/child/resource_dispatcher.h" |
10 #include "content/child/url_response_body_consumer.h" | 10 #include "content/child/url_response_body_consumer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 request_id_(request_id), | 21 request_id_(request_id), |
22 resource_dispatcher_(resource_dispatcher), | 22 resource_dispatcher_(resource_dispatcher), |
23 task_runner_(std::move(task_runner)), | 23 task_runner_(std::move(task_runner)), |
24 weak_factory_(this) {} | 24 weak_factory_(this) {} |
25 | 25 |
26 URLLoaderClientImpl::~URLLoaderClientImpl() { | 26 URLLoaderClientImpl::~URLLoaderClientImpl() { |
27 if (body_consumer_) | 27 if (body_consumer_) |
28 body_consumer_->Cancel(); | 28 body_consumer_->Cancel(); |
29 } | 29 } |
30 | 30 |
31 void URLLoaderClientImpl::Bind( | 31 void URLLoaderClientImpl::Bind(mojom::URLLoaderClientPtr* client_ptr) { |
32 mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info) { | 32 binding_.Bind(client_ptr, task_runner_); |
33 // TODO(yhirano): Use |task_runner_| here. | |
34 // Currently it is unable because of a ChannelAssociatedInterface restriction. | |
35 binding_.Bind(client_ptr_info); | |
36 } | 33 } |
37 | 34 |
38 void URLLoaderClientImpl::SetDefersLoading() { | 35 void URLLoaderClientImpl::SetDefersLoading() { |
39 is_deferred_ = true; | 36 is_deferred_ = true; |
40 if (body_consumer_) | 37 if (body_consumer_) |
41 body_consumer_->SetDefersLoading(); | 38 body_consumer_->SetDefersLoading(); |
42 } | 39 } |
43 | 40 |
44 void URLLoaderClientImpl::UnsetDefersLoading() { | 41 void URLLoaderClientImpl::UnsetDefersLoading() { |
45 is_deferred_ = false; | 42 is_deferred_ = false; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (has_completion_message) { | 102 if (has_completion_message) { |
106 DCHECK_GT(messages.size(), 0u); | 103 DCHECK_GT(messages.size(), 0u); |
107 DCHECK_EQ(messages.back().type(), | 104 DCHECK_EQ(messages.back().type(), |
108 static_cast<uint32_t>(ResourceMsg_RequestComplete::ID)); | 105 static_cast<uint32_t>(ResourceMsg_RequestComplete::ID)); |
109 Dispatch(messages.back()); | 106 Dispatch(messages.back()); |
110 } | 107 } |
111 } | 108 } |
112 | 109 |
113 void URLLoaderClientImpl::OnReceiveResponse( | 110 void URLLoaderClientImpl::OnReceiveResponse( |
114 const ResourceResponseHead& response_head, | 111 const ResourceResponseHead& response_head, |
115 mojom::DownloadedTempFileAssociatedPtrInfo downloaded_file) { | 112 mojom::DownloadedTempFilePtr downloaded_file) { |
116 has_received_response_ = true; | 113 has_received_response_ = true; |
117 downloaded_file_.Bind(std::move(downloaded_file)); | 114 downloaded_file_ = std::move(downloaded_file); |
118 Dispatch(ResourceMsg_ReceivedResponse(request_id_, response_head)); | 115 Dispatch(ResourceMsg_ReceivedResponse(request_id_, response_head)); |
119 } | 116 } |
120 | 117 |
121 void URLLoaderClientImpl::OnReceiveRedirect( | 118 void URLLoaderClientImpl::OnReceiveRedirect( |
122 const net::RedirectInfo& redirect_info, | 119 const net::RedirectInfo& redirect_info, |
123 const ResourceResponseHead& response_head) { | 120 const ResourceResponseHead& response_head) { |
124 DCHECK(!has_received_response_); | 121 DCHECK(!has_received_response_); |
125 DCHECK(!body_consumer_); | 122 DCHECK(!body_consumer_); |
126 Dispatch( | 123 Dispatch( |
127 ResourceMsg_ReceivedRedirect(request_id_, redirect_info, response_head)); | 124 ResourceMsg_ReceivedRedirect(request_id_, redirect_info, response_head)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 177 |
181 void URLLoaderClientImpl::OnUploadProgress(int64_t current_position, | 178 void URLLoaderClientImpl::OnUploadProgress(int64_t current_position, |
182 int64_t total_size, | 179 int64_t total_size, |
183 const base::Closure& ack_callback) { | 180 const base::Closure& ack_callback) { |
184 Dispatch( | 181 Dispatch( |
185 ResourceMsg_UploadProgress(request_id_, current_position, total_size)); | 182 ResourceMsg_UploadProgress(request_id_, current_position, total_size)); |
186 ack_callback.Run(); | 183 ack_callback.Run(); |
187 } | 184 } |
188 | 185 |
189 } // namespace content | 186 } // namespace content |
OLD | NEW |