| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 const net::URLRequestStatus& status, | 273 const net::URLRequestStatus& status, |
| 274 const std::string& security_info) { | 274 const std::string& security_info) { |
| 275 // NOTE: |request_| may be a dangling pointer at this point. | 275 // NOTE: |request_| may be a dangling pointer at this point. |
| 276 VLOG(20) << __FUNCTION__ << "()" | 276 VLOG(20) << __FUNCTION__ << "()" |
| 277 << " request_id = " << request_id | 277 << " request_id = " << request_id |
| 278 << " status.status() = " << status.status() | 278 << " status.status() = " << status.status() |
| 279 << " status.error() = " << status.error(); | 279 << " status.error() = " << status.error(); |
| 280 net::Error error_code = net::OK; | 280 net::Error error_code = net::OK; |
| 281 if (status.status() == net::URLRequestStatus::FAILED) | 281 if (status.status() == net::URLRequestStatus::FAILED) |
| 282 error_code = static_cast<net::Error>(status.error()); // Normal case. | 282 error_code = static_cast<net::Error>(status.error()); // Normal case. |
| 283 // ERR_CONNECTION_CLOSED is allowed since a number of servers in the wild | |
| 284 // advertise a larger Content-Length than the amount of bytes in the message | |
| 285 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, | |
| 286 // and Safari 5.0.4 - treat the download as complete in this case, so we | |
| 287 // follow their lead. | |
| 288 if (error_code == net::ERR_CONNECTION_CLOSED) | |
| 289 error_code = net::OK; | |
| 290 content::DownloadInterruptReason reason = | 283 content::DownloadInterruptReason reason = |
| 291 content::ConvertNetErrorToInterruptReason( | 284 content::ConvertNetErrorToInterruptReason( |
| 292 error_code, content::DOWNLOAD_INTERRUPT_FROM_NETWORK); | 285 error_code, content::DOWNLOAD_INTERRUPT_FROM_NETWORK); |
| 293 | 286 |
| 294 if ((status.status() == net::URLRequestStatus::CANCELED) && | 287 if ((status.status() == net::URLRequestStatus::CANCELED) && |
| 295 (status.error() == net::ERR_ABORTED)) { | 288 (status.error() == net::ERR_ABORTED)) { |
| 296 // TODO(ahendrickson) -- Find a better set of codes to use here, as | 289 // TODO(ahendrickson) -- Find a better set of codes to use here, as |
| 297 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. | 290 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. |
| 298 reason = content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; | 291 reason = content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; |
| 299 } | 292 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 " }", | 422 " }", |
| 430 request_ ? | 423 request_ ? |
| 431 request_->url().spec().c_str() : | 424 request_->url().spec().c_str() : |
| 432 "<NULL request>", | 425 "<NULL request>", |
| 433 download_id_.local(), | 426 download_id_.local(), |
| 434 global_id_.child_id, | 427 global_id_.child_id, |
| 435 global_id_.request_id, | 428 global_id_.request_id, |
| 436 render_view_id_, | 429 render_view_id_, |
| 437 save_info_.file_path.value().c_str()); | 430 save_info_.file_path.value().c_str()); |
| 438 } | 431 } |
| OLD | NEW |