Chromium Code Reviews| 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads(); | 824 profile_->GetOriginalProfile()->GetDownloadManager()->RemoveAllDownloads(); |
| 825 } | 825 } |
| 826 // The null times make the date range unbounded. | 826 // The null times make the date range unbounded. |
| 827 return RemoveDownloadsBetween(base::Time(), base::Time()); | 827 return RemoveDownloadsBetween(base::Time(), base::Time()); |
| 828 } | 828 } |
| 829 | 829 |
| 830 void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) { | 830 void DownloadManager::SavePageAsDownloadStarted(DownloadItem* download_item) { |
| 831 #if !defined(NDEBUG) | 831 #if !defined(NDEBUG) |
| 832 save_page_as_downloads_.insert(download_item); | 832 save_page_as_downloads_.insert(download_item); |
| 833 #endif | 833 #endif |
| 834 // Assign a fake db handle if it is uninitialized. The history cannot hold | |
| 835 // multiple DownloadItems with the same handle. | |
| 836 int64 db_handle = download_item->db_handle(); | |
| 837 if (db_handle == DownloadHistory::kUninitializedHandle) | |
| 838 db_handle = download_history_->GetNextFakeDbHandle(); | |
| 839 download_item->set_db_handle(db_handle); | |
|
Paweł Hajdan Jr.
2011/01/31 08:32:19
nit: Could you put it inside the "if"?
| |
| 840 | |
| 841 history_downloads_[download_item->db_handle()] = download_item; | |
|
Paweł Hajdan Jr.
2011/01/31 08:32:19
nit: Should be sufficient to just use db_handle he
| |
| 834 downloads_.insert(download_item); | 842 downloads_.insert(download_item); |
| 835 } | 843 } |
| 836 | 844 |
| 837 // Initiate a download of a specific URL. We send the request to the | 845 // Initiate a download of a specific URL. We send the request to the |
| 838 // ResourceDispatcherHost, and let it send us responses like a regular | 846 // ResourceDispatcherHost, and let it send us responses like a regular |
| 839 // download. | 847 // download. |
| 840 void DownloadManager::DownloadUrl(const GURL& url, | 848 void DownloadManager::DownloadUrl(const GURL& url, |
| 841 const GURL& referrer, | 849 const GURL& referrer, |
| 842 const std::string& referrer_charset, | 850 const std::string& referrer_charset, |
| 843 TabContents* tab_contents) { | 851 TabContents* tab_contents) { |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 observed_download_manager_->RemoveObserver(this); | 1137 observed_download_manager_->RemoveObserver(this); |
| 1130 } | 1138 } |
| 1131 | 1139 |
| 1132 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1140 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
| 1133 observing_download_manager_->NotifyModelChanged(); | 1141 observing_download_manager_->NotifyModelChanged(); |
| 1134 } | 1142 } |
| 1135 | 1143 |
| 1136 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1144 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
| 1137 observed_download_manager_ = NULL; | 1145 observed_download_manager_ = NULL; |
| 1138 } | 1146 } |
| OLD | NEW |