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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Remove from internal maps. | 180 // Remove from internal maps. |
181 int RemoveDownloadItems(const DownloadVector& pending_deletes); | 181 int RemoveDownloadItems(const DownloadVector& pending_deletes); |
182 | 182 |
183 // Called in response to our request to the DownloadFileManager to | 183 // Called in response to our request to the DownloadFileManager to |
184 // create a DownloadFile. A |reason| of | 184 // create a DownloadFile. A |reason| of |
185 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. | 185 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. |
186 void OnDownloadFileCreated( | 186 void OnDownloadFileCreated( |
187 int32 download_id, content::DownloadInterruptReason reason); | 187 int32 download_id, content::DownloadInterruptReason reason); |
188 | 188 |
189 // Called when a download entry is committed to the persistent store. | 189 // Called when a download entry is committed to the persistent store. |
190 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 190 void OnDownloadItemAddedToPersistentStore(content::DownloadItem* item); |
191 | 191 |
192 // Called when Save Page As entry is committed to the persistent store. | 192 // Called when Save Page As entry is committed to the persistent store. |
193 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 193 void OnSavePageItemAddedToPersistentStore(content::DownloadItem* item); |
194 | 194 |
195 // Factory for creation of downloads items. | 195 // Factory for creation of downloads items. |
196 scoped_ptr<content::DownloadItemFactory> factory_; | 196 scoped_ptr<content::DownloadItemFactory> factory_; |
197 | 197 |
198 // |downloads_| is the owning set for all downloads known to the | 198 // |downloads_| is the owning set for all downloads known to the |
199 // DownloadManager. This includes downloads started by the user in | 199 // DownloadManager. This includes downloads started by the user in |
200 // this session, downloads initialized from the history system, and | 200 // this session, downloads initialized from the history system, and |
201 // "save page as" downloads. All other DownloadItem containers in | 201 // "save page as" downloads. All other DownloadItem containers in |
202 // the DownloadManager are maps; they do not own the DownloadItems. | 202 // the DownloadManager are maps; they do not own the DownloadItems. |
203 // Note that this is the only place (with any functional implications; | 203 // Note that this is the only place (with any functional implications; |
204 // see save_page_downloads_ below) that "save page as" downloads are | 204 // see save_page_downloads_ below) that "save page as" downloads are |
205 // kept, as the DownloadManager's only job is to hold onto those | 205 // kept, as the DownloadManager's only job is to hold onto those |
206 // until destruction. | 206 // until destruction. |
207 // | 207 // |
208 // |active_downloads_| is a map of all downloads that are currently being | 208 // |active_downloads_| is a map of all downloads that are currently being |
209 // processed. The key is the ID assigned by the DownloadFileManager, | 209 // processed. The key is the ID assigned by the DownloadFileManager, |
210 // which is unique for the current session. | 210 // which is unique for the current session. |
211 // | 211 // |
212 // |save_page_downloads_| (if defined) is a collection of all the | |
213 // downloads the "save page as" system has given to us to hold onto | |
214 // until we are destroyed. They key is DownloadFileManager, so it is unique | |
215 // compared to download item. It is only used for debugging. | |
216 // | |
217 // When a download is created through a user action, the corresponding | 212 // When a download is created through a user action, the corresponding |
218 // DownloadItem* is placed in |active_downloads_| and remains there until the | 213 // DownloadItem* is placed in |active_downloads_| and remains there until the |
219 // download is in a terminal state (COMPLETE or CANCELLED). Once it has a | 214 // download is in a terminal state (COMPLETE or CANCELLED). Once it has a |
220 // valid handle, the DownloadItem* is placed in the |history_downloads_| map. | 215 // valid handle, the DownloadItem* is placed in the |history_downloads_| map. |
221 // Downloads from past sessions read from a persisted state from the history | 216 // Downloads from past sessions read from a persisted state from the history |
222 // system are placed directly into |history_downloads_| since they have valid | 217 // system are placed directly into |history_downloads_| since they have valid |
223 // handles in the history system. | 218 // handles in the history system. |
224 | 219 |
225 DownloadMap downloads_; | 220 DownloadMap downloads_; |
226 DownloadMap active_downloads_; | 221 DownloadMap active_downloads_; |
227 DownloadMap save_page_downloads_; | |
228 | 222 |
229 int history_size_; | 223 int history_size_; |
230 | 224 |
231 // True if the download manager has been initialized and requires a shutdown. | 225 // True if the download manager has been initialized and requires a shutdown. |
232 bool shutdown_needed_; | 226 bool shutdown_needed_; |
233 | 227 |
234 // Observers that want to be notified of changes to the set of downloads. | 228 // Observers that want to be notified of changes to the set of downloads. |
235 ObserverList<Observer> observers_; | 229 ObserverList<Observer> observers_; |
236 | 230 |
237 // The current active browser context. | 231 // The current active browser context. |
238 content::BrowserContext* browser_context_; | 232 content::BrowserContext* browser_context_; |
239 | 233 |
240 // Non-owning pointer for handling file writing on the download_thread_. | 234 // Non-owning pointer for handling file writing on the download_thread_. |
241 DownloadFileManager* file_manager_; | 235 DownloadFileManager* file_manager_; |
242 | 236 |
243 // The user's last choice for download directory. This is only used when the | 237 // The user's last choice for download directory. This is only used when the |
244 // user wants us to prompt for a save location for each download. | 238 // user wants us to prompt for a save location for each download. |
245 FilePath last_download_path_; | 239 FilePath last_download_path_; |
246 | 240 |
247 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 241 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
248 content::DownloadManagerDelegate* delegate_; | 242 content::DownloadManagerDelegate* delegate_; |
249 | 243 |
250 net::NetLog* net_log_; | 244 net::NetLog* net_log_; |
251 | 245 |
252 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 246 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
253 }; | 247 }; |
254 | 248 |
255 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 249 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |