| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 // Remove downloads will delete all downloads that have a timestamp that is | 137 // Remove downloads will delete all downloads that have a timestamp that is |
| 138 // the same or more recent than |remove_begin|. The number of downloads | 138 // the same or more recent than |remove_begin|. The number of downloads |
| 139 // deleted is returned back to the caller. | 139 // deleted is returned back to the caller. |
| 140 int RemoveDownloads(const base::Time remove_begin); | 140 int RemoveDownloads(const base::Time remove_begin); |
| 141 | 141 |
| 142 // Remove all downloads will delete all downloads. The number of downloads | 142 // Remove all downloads will delete all downloads. The number of downloads |
| 143 // deleted is returned back to the caller. | 143 // deleted is returned back to the caller. |
| 144 int RemoveAllDownloads(); | 144 int RemoveAllDownloads(); |
| 145 | 145 |
| 146 // Remove the download with id |download_id| from |active_downloads_|. |
| 147 void RemoveFromActiveList(int32 download_id); |
| 148 |
| 146 // Called when a Save Page As download is started. Transfers ownership | 149 // Called when a Save Page As download is started. Transfers ownership |
| 147 // of |download_item| to the DownloadManager. | 150 // of |download_item| to the DownloadManager. |
| 148 void SavePageAsDownloadStarted(DownloadItem* download_item); | 151 void SavePageAsDownloadStarted(DownloadItem* download_item); |
| 149 | 152 |
| 150 // Download the object at the URL. Used in cases such as "Save Link As..." | 153 // Download the object at the URL. Used in cases such as "Save Link As..." |
| 151 void DownloadUrl(const GURL& url, | 154 void DownloadUrl(const GURL& url, |
| 152 const GURL& referrer, | 155 const GURL& referrer, |
| 153 const std::string& referrer_encoding, | 156 const std::string& referrer_encoding, |
| 154 TabContents* tab_contents); | 157 TabContents* tab_contents); |
| 155 | 158 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // the DownloadManager are maps; they do not own the DownloadItems. | 306 // the DownloadManager are maps; they do not own the DownloadItems. |
| 304 // Note that this is the only place (with any functional implications; | 307 // Note that this is the only place (with any functional implications; |
| 305 // see save_page_as_downloads_ below) that "save page as" downloads are | 308 // 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 | 309 // kept, as the DownloadManager's only job is to hold onto those |
| 307 // until destruction. | 310 // until destruction. |
| 308 // | 311 // |
| 309 // |history_downloads_| is map of all downloads in this profile. The key | 312 // |history_downloads_| is map of all downloads in this profile. The key |
| 310 // is the handle returned by the history system, which is unique | 313 // is the handle returned by the history system, which is unique |
| 311 // across sessions. | 314 // across sessions. |
| 312 // | 315 // |
| 316 // |active_downloads_| is a map of all downloads that are currently being |
| 317 // processed. The key is the ID assigned by the ResourceDispatcherHost, |
| 318 // which is unique for the current session. |
| 319 // |
| 313 // |in_progress_| is a map of all downloads that are in progress and that have | 320 // |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 | 321 // not yet received a valid history handle. The key is the ID assigned by the |
| 315 // ResourceDispatcherHost, which is unique for the current session. | 322 // ResourceDispatcherHost, which is unique for the current session. |
| 316 // | 323 // |
| 317 // |save_page_as_downloads_| (if defined) is a collection of all the | 324 // |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 | 325 // downloads the "save page as" system has given to us to hold onto |
| 319 // until we are destroyed. It is only used for debugging. | 326 // until we are destroyed. It is only used for debugging. |
| 320 // | 327 // |
| 321 // When a download is created through a user action, the corresponding | 328 // When a download is created through a user action, the corresponding |
| 322 // DownloadItem* is placed in |in_progress_| and remains there until it has | 329 // 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 | 330 // download has finished. It is also placed in |in_progress_| and remains |
| 324 // handle, the DownloadItem* is placed in the |history_downloads_| | 331 // there until it has received a valid handle from the history system. Once |
| 325 // map. When the download is complete, it is removed from | 332 // it has a valid handle, the DownloadItem* is placed in the |
| 326 // |in_progress_|. Downloads from past sessions read from a | 333 // |history_downloads_| map. When the download is complete, it is removed |
| 334 // from |in_progress_|. Downloads from past sessions read from a |
| 327 // persisted state from the history system are placed directly into | 335 // persisted state from the history system are placed directly into |
| 328 // |history_downloads_| since they have valid handles in the history system. | 336 // |history_downloads_| since they have valid handles in the history system. |
| 329 typedef std::set<DownloadItem*> DownloadSet; | 337 typedef std::set<DownloadItem*> DownloadSet; |
| 330 typedef base::hash_map<int64, DownloadItem*> DownloadMap; | 338 typedef base::hash_map<int64, DownloadItem*> DownloadMap; |
| 331 | 339 |
| 332 DownloadSet downloads_; | 340 DownloadSet downloads_; |
| 333 DownloadMap history_downloads_; | 341 DownloadMap history_downloads_; |
| 334 DownloadMap in_progress_; | 342 DownloadMap in_progress_; |
| 343 DownloadMap active_downloads_; |
| 335 #if !defined(NDEBUG) | 344 #if !defined(NDEBUG) |
| 336 DownloadSet save_page_as_downloads_; | 345 DownloadSet save_page_as_downloads_; |
| 337 #endif | 346 #endif |
| 338 | 347 |
| 339 // True if the download manager has been initialized and requires a shutdown. | 348 // True if the download manager has been initialized and requires a shutdown. |
| 340 bool shutdown_needed_; | 349 bool shutdown_needed_; |
| 341 | 350 |
| 342 // Observers that want to be notified of changes to the set of downloads. | 351 // Observers that want to be notified of changes to the set of downloads. |
| 343 ObserverList<Observer> observers_; | 352 ObserverList<Observer> observers_; |
| 344 | 353 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 371 // The "Save As" dialog box used to ask the user where a file should be | 380 // The "Save As" dialog box used to ask the user where a file should be |
| 372 // saved. | 381 // saved. |
| 373 scoped_refptr<SelectFileDialog> select_file_dialog_; | 382 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 374 | 383 |
| 375 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 384 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
| 376 | 385 |
| 377 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 386 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 378 }; | 387 }; |
| 379 | 388 |
| 380 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 389 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |