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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 void RenameCompletingDownloadFile(content::DownloadId id, | 137 void RenameCompletingDownloadFile(content::DownloadId id, |
138 const FilePath& full_path, | 138 const FilePath& full_path, |
139 bool overwrite_existing_file); | 139 bool overwrite_existing_file); |
140 | 140 |
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 void SetFileFactoryForTesting(scoped_ptr<DownloadFileFactory> file_factory) { | |
148 download_file_factory_.swap(file_factory); | |
cbentzel
2012/03/01 15:44:20
What are you trying to do with the swap here (as o
ahendrickson
2012/03/01 20:19:31
This effectively does the same thing as
download_
cbentzel
2012/03/01 22:32:00
OK, normally when I see swap I expect there to be
ahendrickson
2012/03/02 21:58:47
Went the reset() way.
| |
149 } | |
150 | |
151 DownloadFileFactory* GetFileFactoryForTesting() const { | |
152 return download_file_factory_.get(); // Explicitly NOT a scoped_ptr. | |
153 } | |
154 | |
147 private: | 155 private: |
148 friend class base::RefCountedThreadSafe<DownloadFileManager>; | 156 friend class base::RefCountedThreadSafe<DownloadFileManager>; |
149 friend class DownloadFileManagerTest; | 157 friend class DownloadFileManagerTest; |
150 friend class DownloadManagerTest; | 158 friend class DownloadManagerTest; |
151 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); | 159 FRIEND_TEST_ALL_PREFIXES(DownloadManagerTest, StartDownload); |
152 | 160 |
153 ~DownloadFileManager(); | 161 ~DownloadFileManager(); |
154 | 162 |
155 // Timer helpers for updating the UI about the current progress of a download. | 163 // Timer helpers for updating the UI about the current progress of a download. |
156 void StartUpdateTimer(); | 164 void StartUpdateTimer(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 // is controlled from the FILE thread, and posts updates to the UI thread. | 199 // is controlled from the FILE thread, and posts updates to the UI thread. |
192 base::RepeatingTimer<DownloadFileManager> update_timer_; | 200 base::RepeatingTimer<DownloadFileManager> update_timer_; |
193 | 201 |
194 ResourceDispatcherHost* resource_dispatcher_host_; | 202 ResourceDispatcherHost* resource_dispatcher_host_; |
195 scoped_ptr<DownloadFileFactory> download_file_factory_; | 203 scoped_ptr<DownloadFileFactory> download_file_factory_; |
196 | 204 |
197 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 205 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
198 }; | 206 }; |
199 | 207 |
200 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 208 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
OLD | NEW |