| 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 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 browser context in Chrome. | 8 // active browser context in Chrome. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool Init(content::BrowserContext* browser_context); | 110 bool Init(content::BrowserContext* browser_context); |
| 111 | 111 |
| 112 // Notifications sent from the download thread to the UI thread | 112 // Notifications sent from the download thread to the UI thread |
| 113 void StartDownload(int32 id); | 113 void StartDownload(int32 id); |
| 114 void UpdateDownload(int32 download_id, int64 size); | 114 void UpdateDownload(int32 download_id, int64 size); |
| 115 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 115 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 116 // is not available. | 116 // is not available. |
| 117 void OnResponseCompleted(int32 download_id, int64 size, int os_error, | 117 void OnResponseCompleted(int32 download_id, int64 size, int os_error, |
| 118 const std::string& hash); | 118 const std::string& hash); |
| 119 | 119 |
| 120 // Offthread target for cancelling a particular download. Will be a no-op |
| 121 // if the download has already been cancelled. |
| 122 void CancelDownload(int32 download_id); |
| 123 |
| 124 // Called from DownloadItem to handle the DownloadManager portion of a |
| 125 // Cancel; should not be called from other locations. |
| 126 void DownloadCancelledInternal(DownloadItem* download); |
| 127 |
| 120 // Called from a view when a user clicks a UI button or link. | 128 // Called from a view when a user clicks a UI button or link. |
| 121 void DownloadCancelled(int32 download_id); | |
| 122 void RemoveDownload(int64 download_handle); | 129 void RemoveDownload(int64 download_handle); |
| 123 | 130 |
| 124 // Determine if the download is ready for completion, i.e. has had | 131 // Determine if the download is ready for completion, i.e. has had |
| 125 // all data saved, and completed the filename determination and | 132 // all data saved, and completed the filename determination and |
| 126 // history insertion. | 133 // history insertion. |
| 127 bool IsDownloadReadyForCompletion(DownloadItem* download); | 134 bool IsDownloadReadyForCompletion(DownloadItem* download); |
| 128 | 135 |
| 129 // If all pre-requisites have been met, complete download processing, i.e. | 136 // If all pre-requisites have been met, complete download processing, i.e. |
| 130 // do internal cleanup, file rename, and potentially auto-open. | 137 // do internal cleanup, file rename, and potentially auto-open. |
| 131 // (Dangerous downloads still may block on user acceptance after this | 138 // (Dangerous downloads still may block on user acceptance after this |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // the downloaded file. The UI thread updates the state of the file | 278 // the downloaded file. The UI thread updates the state of the file |
| 272 // and then notifies this update to the file's observer. | 279 // and then notifies this update to the file's observer. |
| 273 void OnFileRemovalDetected(int64 db_handle); | 280 void OnFileRemovalDetected(int64 db_handle); |
| 274 | 281 |
| 275 // Called back after a target path for the file to be downloaded to has been | 282 // Called back after a target path for the file to be downloaded to has been |
| 276 // determined, either automatically based on the suggested file name, or by | 283 // determined, either automatically based on the suggested file name, or by |
| 277 // the user in a Save As dialog box. | 284 // the user in a Save As dialog box. |
| 278 void ContinueDownloadWithPath(DownloadItem* download, | 285 void ContinueDownloadWithPath(DownloadItem* download, |
| 279 const FilePath& chosen_file); | 286 const FilePath& chosen_file); |
| 280 | 287 |
| 281 // Download cancel helper function. | |
| 282 void DownloadCancelledInternal(int download_id, | |
| 283 const DownloadRequestHandle& request_handle); | |
| 284 | |
| 285 // All data has been downloaded. | 288 // All data has been downloaded. |
| 286 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 289 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 287 // is not available. | 290 // is not available. |
| 288 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); | 291 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); |
| 289 | 292 |
| 290 // An error occurred in the download. | 293 // An error occurred in the download. |
| 291 void OnDownloadError(int32 download_id, int64 size, int os_error); | 294 void OnDownloadError(int32 download_id, int64 size, int os_error); |
| 292 | 295 |
| 293 // Updates the delegate about the overall download progress. | 296 // Updates the delegate about the overall download progress. |
| 294 void UpdateDownloadProgress(); | 297 void UpdateDownloadProgress(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // Non-owning pointer for updating the download status. | 374 // Non-owning pointer for updating the download status. |
| 372 base::WeakPtr<DownloadStatusUpdater> status_updater_; | 375 base::WeakPtr<DownloadStatusUpdater> status_updater_; |
| 373 | 376 |
| 374 // The user's last choice for download directory. This is only used when the | 377 // The user's last choice for download directory. This is only used when the |
| 375 // user wants us to prompt for a save location for each download. | 378 // user wants us to prompt for a save location for each download. |
| 376 FilePath last_download_path_; | 379 FilePath last_download_path_; |
| 377 | 380 |
| 378 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 381 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
| 379 DownloadManagerDelegate* delegate_; | 382 DownloadManagerDelegate* delegate_; |
| 380 | 383 |
| 384 // TODO(rdsmith): Remove when http://crbug.com/84508 is fixed. |
| 385 // For debugging only. |
| 386 int64 largest_db_handle_in_history_; |
| 387 |
| 381 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 388 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 382 }; | 389 }; |
| 383 | 390 |
| 384 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 391 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |