| 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 // ResourceDispatcherHost. | 8 // ResourceDispatcherHost. |
| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // The number of downloads currently active on the DownloadFileManager. | 141 // The number of downloads currently active on the DownloadFileManager. |
| 142 // Primarily for testing. | 142 // Primarily for testing. |
| 143 int NumberOfActiveDownloads() const { | 143 int NumberOfActiveDownloads() const { |
| 144 return downloads_.size(); | 144 return downloads_.size(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 friend class base::RefCountedThreadSafe<DownloadFileManager>; | 148 friend class base::RefCountedThreadSafe<DownloadFileManager>; |
| 149 friend class DownloadFileManagerTest; | 149 friend class DownloadFileManagerTest; |
| 150 friend class DownloadManagerTest; | 150 friend class DownloadManagerTest; |
| 151 friend class TestFileErrorInjectorImpl; |
| 151 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); | 152 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); |
| 152 | 153 |
| 153 ~DownloadFileManager(); | 154 ~DownloadFileManager(); |
| 154 | 155 |
| 156 // This is only for unit tests. |
| 157 void SetFileFactory(DownloadFileFactory* file_factory) { |
| 158 download_file_factory_.reset(file_factory); |
| 159 } |
| 160 |
| 155 // 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. |
| 156 void StartUpdateTimer(); | 162 void StartUpdateTimer(); |
| 157 void StopUpdateTimer(); | 163 void StopUpdateTimer(); |
| 158 void UpdateInProgressDownloads(); | 164 void UpdateInProgressDownloads(); |
| 159 | 165 |
| 160 // Clean up helper that runs on the download thread. | 166 // Clean up helper that runs on the download thread. |
| 161 void OnShutdown(); | 167 void OnShutdown(); |
| 162 | 168 |
| 163 // Creates DownloadFile on FILE thread and continues starting the download | 169 // Creates DownloadFile on FILE thread and continues starting the download |
| 164 // process. | 170 // process. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 191 // 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. |
| 192 base::RepeatingTimer<DownloadFileManager> update_timer_; | 198 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 193 | 199 |
| 194 ResourceDispatcherHost* resource_dispatcher_host_; | 200 ResourceDispatcherHost* resource_dispatcher_host_; |
| 195 scoped_ptr<DownloadFileFactory> download_file_factory_; | 201 scoped_ptr<DownloadFileFactory> download_file_factory_; |
| 196 | 202 |
| 197 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 203 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 198 }; | 204 }; |
| 199 | 205 |
| 200 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 206 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |