Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
| 6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
| 7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
| 8 // active profile in Chrome. | 8 // active profile in Chrome. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 void SearchDownloads(const string16& query, | 112 void SearchDownloads(const string16& query, |
| 113 std::vector<DownloadItem*>* result); | 113 std::vector<DownloadItem*>* result); |
| 114 | 114 |
| 115 // Returns true if initialized properly. | 115 // Returns true if initialized properly. |
| 116 bool Init(Profile* profile); | 116 bool Init(Profile* profile); |
| 117 | 117 |
| 118 // Notifications sent from the download thread to the UI thread | 118 // Notifications sent from the download thread to the UI thread |
| 119 void StartDownload(DownloadCreateInfo* info); | 119 void StartDownload(DownloadCreateInfo* info); |
| 120 void UpdateDownload(int32 download_id, int64 size); | 120 void UpdateDownload(int32 download_id, int64 size); |
| 121 void OnAllDataSaved(int32 download_id, int64 size); | 121 void OnAllDataSaved(int32 download_id, int64 size); |
| 122 void OnDownloadFileCompleted(int32 download_id); | |
| 122 | 123 |
| 123 // Called from a view when a user clicks a UI button or link. | 124 // Called from a view when a user clicks a UI button or link. |
| 124 void DownloadCancelled(int32 download_id); | 125 void DownloadCancelled(int32 download_id); |
| 125 void PauseDownload(int32 download_id, bool pause); | 126 void PauseDownload(int32 download_id, bool pause); |
| 126 void RemoveDownload(int64 download_handle); | 127 void RemoveDownload(int64 download_handle); |
| 127 | 128 |
| 128 // Called when the download is renamed to its final name. | 129 // Called when the download is renamed to its final name. |
| 129 void DownloadRenamedToFinalName(int download_id, const FilePath& full_path); | 130 void DownloadRenamedToFinalName(int download_id, const FilePath& full_path); |
| 130 | 131 |
| 131 // Remove downloads after remove_begin (inclusive) and before remove_end | 132 // Remove downloads after remove_begin (inclusive) and before remove_end |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 // the DownloadManager are maps; they do not own the DownloadItems. | 304 // the DownloadManager are maps; they do not own the DownloadItems. |
| 304 // Note that this is the only place (with any functional implications; | 305 // Note that this is the only place (with any functional implications; |
| 305 // see save_page_as_downloads_ below) that "save page as" downloads are | 306 // see save_page_as_downloads_ below) that "save page as" downloads are |
| 306 // kept, as the DownloadManager's only job is to hold onto those | 307 // kept, as the DownloadManager's only job is to hold onto those |
| 307 // until destruction. | 308 // until destruction. |
| 308 // | 309 // |
| 309 // |history_downloads_| is map of all downloads in this profile. The key | 310 // |history_downloads_| is map of all downloads in this profile. The key |
| 310 // is the handle returned by the history system, which is unique | 311 // is the handle returned by the history system, which is unique |
| 311 // across sessions. | 312 // across sessions. |
| 312 // | 313 // |
| 314 // |active_downloads_| is a map of all downloads that are currently being | |
| 315 // processed. The key is the ID assigned by the ResourceDispatcherHost, | |
|
Paweł Hajdan Jr.
2011/01/05 08:11:16
nit: "being processed" is extremely vague. Could y
ahendrickson
2011/01/06 16:48:52
Is "active" any better?
It will eventually replac
Paweł Hajdan Jr.
2011/01/06 20:39:34
Okay, ignore it for now. We can do it the right wa
| |
| 316 // which is unique for the current session. | |
| 317 // | |
| 313 // |in_progress_| is a map of all downloads that are in progress and that have | 318 // |in_progress_| is a map of all downloads that are in progress and that have |
| 314 // not yet received a valid history handle. The key is the ID assigned by the | 319 // not yet received a valid history handle. The key is the ID assigned by the |
| 315 // ResourceDispatcherHost, which is unique for the current session. | 320 // ResourceDispatcherHost, which is unique for the current session. |
| 316 // | 321 // |
| 317 // |save_page_as_downloads_| (if defined) is a collection of all the | 322 // |save_page_as_downloads_| (if defined) is a collection of all the |
| 318 // downloads the "save page as" system has given to us to hold onto | 323 // downloads the "save page as" system has given to us to hold onto |
| 319 // until we are destroyed. It is only used for debugging. | 324 // until we are destroyed. It is only used for debugging. |
| 320 // | 325 // |
| 321 // When a download is created through a user action, the corresponding | 326 // When a download is created through a user action, the corresponding |
| 322 // DownloadItem* is placed in |in_progress_| and remains there until it has | 327 // DownloadItem* is placed in |active_downloads_| and remains there until the |
| 323 // received a valid handle from the history system. Once it has a valid | 328 // download has finished. It is also placed in |in_progress_| and remains |
| 324 // handle, the DownloadItem* is placed in the |history_downloads_| | 329 // there until it has received a valid handle from the history system. Once |
| 325 // map. When the download is complete, it is removed from | 330 // it has a valid handle, the DownloadItem* is placed in the |
| 326 // |in_progress_|. Downloads from past sessions read from a | 331 // |history_downloads_| map. When the download is complete, it is removed |
| 332 // from |in_progress_|. Downloads from past sessions read from a | |
| 327 // persisted state from the history system are placed directly into | 333 // persisted state from the history system are placed directly into |
| 328 // |history_downloads_| since they have valid handles in the history system. | 334 // |history_downloads_| since they have valid handles in the history system. |
| 329 typedef std::set<DownloadItem*> DownloadSet; | 335 typedef std::set<DownloadItem*> DownloadSet; |
| 330 typedef base::hash_map<int64, DownloadItem*> DownloadMap; | 336 typedef base::hash_map<int64, DownloadItem*> DownloadMap; |
| 331 | 337 |
| 332 DownloadSet downloads_; | 338 DownloadSet downloads_; |
| 333 DownloadMap history_downloads_; | 339 DownloadMap history_downloads_; |
| 334 DownloadMap in_progress_; | 340 DownloadMap in_progress_; |
| 341 DownloadMap active_downloads_; | |
| 335 #if !defined(NDEBUG) | 342 #if !defined(NDEBUG) |
| 336 DownloadSet save_page_as_downloads_; | 343 DownloadSet save_page_as_downloads_; |
| 337 #endif | 344 #endif |
| 338 | 345 |
| 339 // True if the download manager has been initialized and requires a shutdown. | 346 // True if the download manager has been initialized and requires a shutdown. |
| 340 bool shutdown_needed_; | 347 bool shutdown_needed_; |
| 341 | 348 |
| 342 // Observers that want to be notified of changes to the set of downloads. | 349 // Observers that want to be notified of changes to the set of downloads. |
| 343 ObserverList<Observer> observers_; | 350 ObserverList<Observer> observers_; |
| 344 | 351 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 371 // The "Save As" dialog box used to ask the user where a file should be | 378 // The "Save As" dialog box used to ask the user where a file should be |
| 372 // saved. | 379 // saved. |
| 373 scoped_refptr<SelectFileDialog> select_file_dialog_; | 380 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 374 | 381 |
| 375 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 382 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
| 376 | 383 |
| 377 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 384 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 378 }; | 385 }; |
| 379 | 386 |
| 380 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 387 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |