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/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 download_history_->UpdateEntry(download); | 625 download_history_->UpdateEntry(download); |
626 } | 626 } |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
630 void DownloadManager::OnResponseCompleted(int32 download_id, | 630 void DownloadManager::OnResponseCompleted(int32 download_id, |
631 int64 size, | 631 int64 size, |
632 int os_error, | 632 int os_error, |
633 const std::string& hash) { | 633 const std::string& hash) { |
634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
635 if (os_error == 0) { | 635 // ERR_CONNECTION_CLOSED is allowed since a number of servers in the wild |
| 636 // advertise a larger Content-Length than the amount of bytes in the message |
| 637 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, |
| 638 // and Safari 5.0.4 - treat the download as complete in this case, so we |
| 639 // follow their lead. |
| 640 if (os_error == 0 || os_error == net::ERR_CONNECTION_CLOSED) { |
636 OnAllDataSaved(download_id, size, hash); | 641 OnAllDataSaved(download_id, size, hash); |
637 } else { | 642 } else { |
638 OnDownloadError(download_id, size, os_error); | 643 OnDownloadError(download_id, size, os_error); |
639 } | 644 } |
640 } | 645 } |
641 | 646 |
642 void DownloadManager::OnAllDataSaved(int32 download_id, | 647 void DownloadManager::OnAllDataSaved(int32 download_id, |
643 int64 size, | 648 int64 size, |
644 const std::string& hash) { | 649 const std::string& hash) { |
645 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id | 650 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 observed_download_manager_->RemoveObserver(this); | 1309 observed_download_manager_->RemoveObserver(this); |
1305 } | 1310 } |
1306 | 1311 |
1307 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1312 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
1308 observing_download_manager_->NotifyModelChanged(); | 1313 observing_download_manager_->NotifyModelChanged(); |
1309 } | 1314 } |
1310 | 1315 |
1311 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1316 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
1312 observed_download_manager_ = NULL; | 1317 observed_download_manager_ = NULL; |
1313 } | 1318 } |
OLD | NEW |