| 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 "chrome/browser/download/download_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 download_history_->UpdateEntry(download); | 532 download_history_->UpdateEntry(download); |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 | 536 |
| 537 void DownloadManager::OnResponseCompleted(int32 download_id, | 537 void DownloadManager::OnResponseCompleted(int32 download_id, |
| 538 int64 size, | 538 int64 size, |
| 539 int os_error, | 539 int os_error, |
| 540 const std::string& hash) { | 540 const std::string& hash) { |
| 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 542 if (os_error == 0) { | 542 // ERR_CONNECTION_CLOSED is allowed since a number of servers in the wild |
| 543 // advertise a larger Content-Length than the amount of bytes in the message |
| 544 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, |
| 545 // and Safari 5.0.4 - treat the download as complete in this case, so we |
| 546 // follow their lead. |
| 547 if (os_error == 0 || os_error == net::ERR_CONNECTION_CLOSED) { |
| 543 OnAllDataSaved(download_id, size, hash); | 548 OnAllDataSaved(download_id, size, hash); |
| 544 } else { | 549 } else { |
| 545 OnDownloadError(download_id, size, os_error); | 550 OnDownloadError(download_id, size, os_error); |
| 546 } | 551 } |
| 547 } | 552 } |
| 548 | 553 |
| 549 void DownloadManager::OnAllDataSaved(int32 download_id, | 554 void DownloadManager::OnAllDataSaved(int32 download_id, |
| 550 int64 size, | 555 int64 size, |
| 551 const std::string& hash) { | 556 const std::string& hash) { |
| 552 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id | 557 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 observed_download_manager_->RemoveObserver(this); | 1179 observed_download_manager_->RemoveObserver(this); |
| 1175 } | 1180 } |
| 1176 | 1181 |
| 1177 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1182 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
| 1178 observing_download_manager_->NotifyModelChanged(); | 1183 observing_download_manager_->NotifyModelChanged(); |
| 1179 } | 1184 } |
| 1180 | 1185 |
| 1181 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1186 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
| 1182 observed_download_manager_ = NULL; | 1187 observed_download_manager_ = NULL; |
| 1183 } | 1188 } |
| OLD | NEW |