OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 int request_id, | 225 int request_id, |
226 const net::URLRequestStatus& status, | 226 const net::URLRequestStatus& status, |
227 const std::string& security_info) { | 227 const std::string& security_info) { |
228 VLOG(20) << __FUNCTION__ << "()" << DebugString() | 228 VLOG(20) << __FUNCTION__ << "()" << DebugString() |
229 << " request_id = " << request_id | 229 << " request_id = " << request_id |
230 << " status.status() = " << status.status() | 230 << " status.status() = " << status.status() |
231 << " status.error() = " << status.error(); | 231 << " status.error() = " << status.error(); |
232 net::Error error_code = net::OK; | 232 net::Error error_code = net::OK; |
233 if (status.status() == net::URLRequestStatus::FAILED) | 233 if (status.status() == net::URLRequestStatus::FAILED) |
234 error_code = static_cast<net::Error>(status.error()); // Normal case. | 234 error_code = static_cast<net::Error>(status.error()); // Normal case. |
235 // ERR_CONTENT_LENGTH_MISMATCH is allowed since a number of servers in the | 235 // ERR_CONNECTION_CLOSED is allowed since a number of servers in the wild |
236 // wild advertise a larger Content-Length than the amount of bytes in the | 236 // advertise a larger Content-Length than the amount of bytes in the message |
237 // message body, and then close the connection. Other browsers - IE8, | 237 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, |
238 // Firefox 4.0.1, and Safari 5.0.4 - treat the download as complete in this | 238 // and Safari 5.0.4 - treat the download as complete in this case, so we |
239 // case, so we follow their lead. | 239 // follow their lead. |
240 if (error_code == net::ERR_CONTENT_LENGTH_MISMATCH) | 240 if (error_code == net::ERR_CONNECTION_CLOSED) |
241 error_code = net::OK; | 241 error_code = net::OK; |
242 InterruptReason reason = | 242 InterruptReason reason = |
243 ConvertNetErrorToInterruptReason(error_code, | 243 ConvertNetErrorToInterruptReason(error_code, |
244 DOWNLOAD_INTERRUPT_FROM_NETWORK); | 244 DOWNLOAD_INTERRUPT_FROM_NETWORK); |
245 if ((status.status() == net::URLRequestStatus::CANCELED) && | 245 if ((status.status() == net::URLRequestStatus::CANCELED) && |
246 (status.error() == net::ERR_ABORTED)) { | 246 (status.error() == net::ERR_ABORTED)) { |
247 // TODO(ahendrickson) -- Find a better set of codes to use here, as | 247 // TODO(ahendrickson) -- Find a better set of codes to use here, as |
248 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. | 248 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. |
249 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. | 249 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. |
250 } | 250 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 " render_view_id_ = " "%d" | 324 " render_view_id_ = " "%d" |
325 " save_info_.file_path = \"%" PRFilePath "\"" | 325 " save_info_.file_path = \"%" PRFilePath "\"" |
326 " }", | 326 " }", |
327 request_->url().spec().c_str(), | 327 request_->url().spec().c_str(), |
328 download_id_.local(), | 328 download_id_.local(), |
329 global_id_.child_id, | 329 global_id_.child_id, |
330 global_id_.request_id, | 330 global_id_.request_id, |
331 render_view_id_, | 331 render_view_id_, |
332 save_info_.file_path.value().c_str()); | 332 save_info_.file_path.value().c_str()); |
333 } | 333 } |
OLD | NEW |