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 #include "content/browser/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 void DownloadResourceHandler::OnWillStart( | 166 void DownloadResourceHandler::OnWillStart( |
167 const GURL& url, | 167 const GURL& url, |
168 std::unique_ptr<ResourceController> controller) { | 168 std::unique_ptr<ResourceController> controller) { |
169 controller->Resume(); | 169 controller->Resume(); |
170 } | 170 } |
171 | 171 |
172 // Create a new buffer, which will be handed to the download thread for file | 172 // Create a new buffer, which will be handed to the download thread for file |
173 // writing and deletion. | 173 // writing and deletion. |
174 bool DownloadResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 174 void DownloadResourceHandler::OnWillRead( |
175 int* buf_size) { | 175 scoped_refptr<net::IOBuffer>* buf, |
176 return core_.OnWillRead(buf, buf_size); | 176 int* buf_size, |
| 177 std::unique_ptr<ResourceController> controller) { |
| 178 if (!core_.OnWillRead(buf, buf_size)) { |
| 179 controller->Cancel(); |
| 180 return; |
| 181 } |
| 182 |
| 183 controller->Resume(); |
177 } | 184 } |
178 | 185 |
179 // Pass the buffer to the download file writer. | 186 // Pass the buffer to the download file writer. |
180 void DownloadResourceHandler::OnReadCompleted( | 187 void DownloadResourceHandler::OnReadCompleted( |
181 int bytes_read, | 188 int bytes_read, |
182 std::unique_ptr<ResourceController> controller) { | 189 std::unique_ptr<ResourceController> controller) { |
183 DCHECK(!has_controller()); | 190 DCHECK(!has_controller()); |
184 | 191 |
185 bool defer = false; | 192 bool defer = false; |
186 if (!core_.OnReadCompleted(bytes_read, &defer)) { | 193 if (!core_.OnReadCompleted(bytes_read, &defer)) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 " }", | 282 " }", |
276 request() ? | 283 request() ? |
277 request()->url().spec().c_str() : | 284 request()->url().spec().c_str() : |
278 "<NULL request>", | 285 "<NULL request>", |
279 info->GetChildID(), | 286 info->GetChildID(), |
280 info->GetRequestID(), | 287 info->GetRequestID(), |
281 info->GetRouteID()); | 288 info->GetRouteID()); |
282 } | 289 } |
283 | 290 |
284 } // namespace content | 291 } // namespace content |
OLD | NEW |