| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The DownloadFileManager owns a set of DownloadFile objects, each of which | 5 // The DownloadFileManager owns a set of DownloadFile objects, each of which |
| 6 // represent one in progress download and performs the disk IO for that | 6 // represent one in progress download and performs the disk IO for that |
| 7 // download. The DownloadFileManager itself is a singleton object owned by the | 7 // download. The DownloadFileManager itself is a singleton object owned by the |
| 8 // ResourceDispatcherHostImpl. | 8 // ResourceDispatcherHostImpl. |
| 9 // | 9 // |
| 10 // The DownloadFileManager uses the file_thread for performing file write | 10 // The DownloadFileManager uses the file_thread for performing file write |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void RenameCompletingDownloadFile(content::DownloadId id, | 135 void RenameCompletingDownloadFile(content::DownloadId id, |
| 136 const FilePath& full_path, | 136 const FilePath& full_path, |
| 137 bool overwrite_existing_file); | 137 bool overwrite_existing_file); |
| 138 | 138 |
| 139 // The number of downloads currently active on the DownloadFileManager. | 139 // The number of downloads currently active on the DownloadFileManager. |
| 140 // Primarily for testing. | 140 // Primarily for testing. |
| 141 int NumberOfActiveDownloads() const { | 141 int NumberOfActiveDownloads() const { |
| 142 return downloads_.size(); | 142 return downloads_.size(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void SetFileFactoryForTesting(scoped_ptr<DownloadFileFactory> file_factory) { |
| 146 download_file_factory_.reset(file_factory.release()); |
| 147 } |
| 148 |
| 149 DownloadFileFactory* GetFileFactoryForTesting() const { |
| 150 return download_file_factory_.get(); // Explicitly NOT a scoped_ptr. |
| 151 } |
| 152 |
| 145 private: | 153 private: |
| 146 friend class base::RefCountedThreadSafe<DownloadFileManager>; | 154 friend class base::RefCountedThreadSafe<DownloadFileManager>; |
| 147 friend class DownloadFileManagerTest; | 155 friend class DownloadFileManagerTest; |
| 148 friend class DownloadManagerTest; | 156 friend class DownloadManagerTest; |
| 149 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); | 157 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); |
| 150 | 158 |
| 151 ~DownloadFileManager(); | 159 ~DownloadFileManager(); |
| 152 | 160 |
| 153 // Timer helpers for updating the UI about the current progress of a download. | 161 // Timer helpers for updating the UI about the current progress of a download. |
| 154 void StartUpdateTimer(); | 162 void StartUpdateTimer(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Schedule periodic updates of the download progress. This timer | 196 // Schedule periodic updates of the download progress. This timer |
| 189 // is controlled from the FILE thread, and posts updates to the UI thread. | 197 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 190 base::RepeatingTimer<DownloadFileManager> update_timer_; | 198 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 191 | 199 |
| 192 scoped_ptr<DownloadFileFactory> download_file_factory_; | 200 scoped_ptr<DownloadFileFactory> download_file_factory_; |
| 193 | 201 |
| 194 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 202 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 195 }; | 203 }; |
| 196 | 204 |
| 197 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 205 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |