| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Returns all non-temporary downloads matching |query|. Empty query matches | 105 // Returns all non-temporary downloads matching |query|. Empty query matches |
| 106 // everything. | 106 // everything. |
| 107 void SearchDownloads(const string16& query, DownloadVector* result); | 107 void SearchDownloads(const string16& query, DownloadVector* result); |
| 108 | 108 |
| 109 // Returns true if initialized properly. | 109 // Returns true if initialized properly. |
| 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 |
| 116 // |download_id| is the ID of the download. |
| 117 // |size| is the number of bytes that have been downloaded. |
| 115 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 118 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 116 // is not available. | 119 // is not available. |
| 117 void OnResponseCompleted(int32 download_id, int64 size, int os_error, | 120 void OnResponseCompleted(int32 download_id, int64 size, |
| 118 const std::string& hash); | 121 const std::string& hash); |
| 119 | 122 |
| 120 // Offthread target for cancelling a particular download. Will be a no-op | 123 // Offthread target for cancelling a particular download. Will be a no-op |
| 121 // if the download has already been cancelled. | 124 // if the download has already been cancelled. |
| 122 void CancelDownload(int32 download_id); | 125 void CancelDownload(int32 download_id); |
| 123 | 126 |
| 127 // Called when there is an error in the download. |
| 128 // |download_id| is the ID of the download. |
| 129 // |size| is the number of bytes that are currently downloaded. |
| 130 // |error| is a download error code. Indicates what caused the interruption. |
| 131 void OnDownloadError(int32 download_id, int64 size, int error); |
| 132 |
| 124 // Called from DownloadItem to handle the DownloadManager portion of a | 133 // Called from DownloadItem to handle the DownloadManager portion of a |
| 125 // Cancel; should not be called from other locations. | 134 // Cancel; should not be called from other locations. |
| 126 void DownloadCancelledInternal(DownloadItem* download); | 135 void DownloadCancelledInternal(DownloadItem* download); |
| 127 | 136 |
| 128 // Called from a view when a user clicks a UI button or link. | 137 // Called from a view when a user clicks a UI button or link. |
| 129 void RemoveDownload(int64 download_handle); | 138 void RemoveDownload(int64 download_handle); |
| 130 | 139 |
| 131 // Determine if the download is ready for completion, i.e. has had | 140 // Determine if the download is ready for completion, i.e. has had |
| 132 // all data saved, and completed the filename determination and | 141 // all data saved, and completed the filename determination and |
| 133 // history insertion. | 142 // history insertion. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // determined, either automatically based on the suggested file name, or by | 292 // determined, either automatically based on the suggested file name, or by |
| 284 // the user in a Save As dialog box. | 293 // the user in a Save As dialog box. |
| 285 void ContinueDownloadWithPath(DownloadItem* download, | 294 void ContinueDownloadWithPath(DownloadItem* download, |
| 286 const FilePath& chosen_file); | 295 const FilePath& chosen_file); |
| 287 | 296 |
| 288 // All data has been downloaded. | 297 // All data has been downloaded. |
| 289 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 298 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 290 // is not available. | 299 // is not available. |
| 291 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); | 300 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); |
| 292 | 301 |
| 293 // An error occurred in the download. | 302 // Retrieves the download from the |download_id|. |
| 294 void OnDownloadError(int32 download_id, int64 size, int os_error); | 303 // Returns NULL if the download is not active. |
| 304 DownloadItem* GetActiveDownload(int32 download_id); |
| 305 |
| 306 // Removes |download| from the active and in progress maps. |
| 307 // Called when the download is cancelled or has an error. |
| 308 // Does nothing if the download is not in the history DB. |
| 309 void RemoveFromActiveList(DownloadItem* download); |
| 295 | 310 |
| 296 // Updates the delegate about the overall download progress. | 311 // Updates the delegate about the overall download progress. |
| 297 void UpdateDownloadProgress(); | 312 void UpdateDownloadProgress(); |
| 298 | 313 |
| 299 // Inform observers that the model has changed. | 314 // Inform observers that the model has changed. |
| 300 void NotifyModelChanged(); | 315 void NotifyModelChanged(); |
| 301 | 316 |
| 302 // Debugging routine to confirm relationship between below | 317 // Debugging routine to confirm relationship between below |
| 303 // containers; no-op if NDEBUG. | 318 // containers; no-op if NDEBUG. |
| 304 void AssertContainersConsistent() const; | 319 void AssertContainersConsistent() const; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 DownloadManagerDelegate* delegate_; | 397 DownloadManagerDelegate* delegate_; |
| 383 | 398 |
| 384 // TODO(rdsmith): Remove when http://crbug.com/84508 is fixed. | 399 // TODO(rdsmith): Remove when http://crbug.com/84508 is fixed. |
| 385 // For debugging only. | 400 // For debugging only. |
| 386 int64 largest_db_handle_in_history_; | 401 int64 largest_db_handle_in_history_; |
| 387 | 402 |
| 388 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 403 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 389 }; | 404 }; |
| 390 | 405 |
| 391 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 406 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |