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 // 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 class ResourceDispatcherHost; | 62 class ResourceDispatcherHost; |
| 63 | 63 |
| 64 namespace content { | 64 namespace content { |
| 65 class DownloadBuffer; | 65 class DownloadBuffer; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Manages all in progress downloads. | 68 // Manages all in progress downloads. |
| 69 class CONTENT_EXPORT DownloadFileManager | 69 class CONTENT_EXPORT DownloadFileManager |
| 70 : public base::RefCountedThreadSafe<DownloadFileManager> { | 70 : public base::RefCountedThreadSafe<DownloadFileManager> { |
| 71 public: | 71 public: |
| 72 explicit DownloadFileManager(ResourceDispatcherHost* rdh); | 72 class DownloadFileFactory { |
| 73 public: | |
| 74 virtual ~DownloadFileFactory() {} | |
| 75 | |
| 76 virtual DownloadFile* GetFile(DownloadCreateInfo* info, | |
|
Randy Smith (Not in Mondays)
2011/12/05 22:25:38
nit, suggestion: I'd call this CreateFile.
ahendrickson
2011/12/07 19:55:15
Done.
| |
| 77 const DownloadRequestHandle& request_handle, | |
| 78 DownloadManager* download_manager) = 0; | |
| 79 }; | |
| 80 | |
| 81 // Takes ownership of the factory. | |
| 82 DownloadFileManager(ResourceDispatcherHost* rdh, | |
| 83 DownloadFileFactory* factory); | |
| 73 | 84 |
| 74 // Called on shutdown on the UI thread. | 85 // Called on shutdown on the UI thread. |
| 75 void Shutdown(); | 86 void Shutdown(); |
| 76 | 87 |
| 77 // Called on UI thread to make DownloadFileManager start the download. | 88 // Called on UI thread to make DownloadFileManager start the download. |
| 78 void StartDownload(DownloadCreateInfo* info, | 89 void StartDownload(DownloadCreateInfo* info, |
| 79 const DownloadRequestHandle& request_handle); | 90 const DownloadRequestHandle& request_handle); |
| 80 | 91 |
| 81 // Handlers for notifications sent from the IO thread and run on the | 92 // Handlers for notifications sent from the IO thread and run on the |
| 82 // FILE thread. | 93 // FILE thread. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap; | 169 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap; |
| 159 | 170 |
| 160 // A map of all in progress downloads. It owns the download files. | 171 // A map of all in progress downloads. It owns the download files. |
| 161 DownloadFileMap downloads_; | 172 DownloadFileMap downloads_; |
| 162 | 173 |
| 163 // Schedule periodic updates of the download progress. This timer | 174 // Schedule periodic updates of the download progress. This timer |
| 164 // is controlled from the FILE thread, and posts updates to the UI thread. | 175 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 165 base::RepeatingTimer<DownloadFileManager> update_timer_; | 176 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 166 | 177 |
| 167 ResourceDispatcherHost* resource_dispatcher_host_; | 178 ResourceDispatcherHost* resource_dispatcher_host_; |
| 179 DownloadFileFactory* download_file_factory_; | |
|
cbentzel
2011/12/07 18:58:21
this should be a scoped_ptr if it takes ownership
ahendrickson
2011/12/07 19:55:15
Done.
| |
| 168 | 180 |
| 169 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 181 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 170 }; | 182 }; |
| 171 | 183 |
| 172 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 184 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |