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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 int request_id, | 208 int request_id, |
209 const net::URLRequestStatus& status, | 209 const net::URLRequestStatus& status, |
210 const std::string& security_info) { | 210 const std::string& security_info) { |
211 VLOG(20) << __FUNCTION__ << "()" << DebugString() | 211 VLOG(20) << __FUNCTION__ << "()" << DebugString() |
212 << " request_id = " << request_id | 212 << " request_id = " << request_id |
213 << " status.status() = " << status.status() | 213 << " status.status() = " << status.status() |
214 << " status.error() = " << status.error(); | 214 << " status.error() = " << status.error(); |
215 net::Error error_code = net::OK; | 215 net::Error error_code = net::OK; |
216 if (status.status() == net::URLRequestStatus::FAILED) | 216 if (status.status() == net::URLRequestStatus::FAILED) |
217 error_code = static_cast<net::Error>(status.error()); // Normal case. | 217 error_code = static_cast<net::Error>(status.error()); // Normal case. |
218 // ERR_CONNECTION_CLOSED is allowed since a number of servers in the wild | 218 // ERR_CONTENT_LENGTH_MISMATCH is allowed since a number of servers in the |
219 // advertise a larger Content-Length than the amount of bytes in the message | 219 // wild advertise a larger Content-Length than the amount of bytes in the |
220 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, | 220 // message body, and then close the connection. Other browsers - IE8, |
221 // and Safari 5.0.4 - treat the download as complete in this case, so we | 221 // Firefox 4.0.1, and Safari 5.0.4 - treat the download as complete in this |
222 // follow their lead. | 222 // case, so we follow their lead. |
223 if (error_code == net::ERR_CONNECTION_CLOSED) | 223 if (error_code == net::ERR_CONTENT_LENGTH_MISMATCH) |
224 error_code = net::OK; | 224 error_code = net::OK; |
225 InterruptReason reason = | 225 InterruptReason reason = |
226 ConvertNetErrorToInterruptReason(error_code, | 226 ConvertNetErrorToInterruptReason(error_code, |
227 DOWNLOAD_INTERRUPT_FROM_NETWORK); | 227 DOWNLOAD_INTERRUPT_FROM_NETWORK); |
228 if ((status.status() == net::URLRequestStatus::CANCELED) && | 228 if ((status.status() == net::URLRequestStatus::CANCELED) && |
229 (status.error() == net::ERR_ABORTED)) { | 229 (status.error() == net::ERR_ABORTED)) { |
230 // TODO(ahendrickson) -- Find a better set of codes to use here, as | 230 // TODO(ahendrickson) -- Find a better set of codes to use here, as |
231 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. | 231 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. |
232 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. | 232 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. |
233 } | 233 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 " render_view_id_ = " "%d" | 304 " render_view_id_ = " "%d" |
305 " save_info_.file_path = \"%" PRFilePath "\"" | 305 " save_info_.file_path = \"%" PRFilePath "\"" |
306 " }", | 306 " }", |
307 request_->url().spec().c_str(), | 307 request_->url().spec().c_str(), |
308 download_id_.local(), | 308 download_id_.local(), |
309 global_id_.child_id, | 309 global_id_.child_id, |
310 global_id_.request_id, | 310 global_id_.request_id, |
311 render_view_id_, | 311 render_view_id_, |
312 save_info_.file_path.value().c_str()); | 312 save_info_.file_path.value().c_str()); |
313 } | 313 } |
OLD | NEW |