| 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 profile in Chrome. | 8 // active profile in Chrome. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Returns all non-temporary downloads matching |query|. Empty query matches | 109 // Returns all non-temporary downloads matching |query|. Empty query matches |
| 110 // everything. | 110 // everything. |
| 111 void SearchDownloads(const string16& query, DownloadVector* result); | 111 void SearchDownloads(const string16& query, DownloadVector* result); |
| 112 | 112 |
| 113 // Returns true if initialized properly. | 113 // Returns true if initialized properly. |
| 114 bool Init(Profile* profile); | 114 bool Init(Profile* profile); |
| 115 | 115 |
| 116 // Notifications sent from the download thread to the UI thread | 116 // Notifications sent from the download thread to the UI thread |
| 117 void StartDownload(int32 id); | 117 void StartDownload(int32 id); |
| 118 void UpdateDownload(int32 download_id, int64 size); | 118 void UpdateDownload(int32 download_id, int64 size); |
| 119 |
| 120 // |download_id| is the ID of the download. |
| 121 // |size| is the number of bytes that have been downloaded. |
| 119 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 122 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 120 // is not available. | 123 // is not available. |
| 121 void OnResponseCompleted(int32 download_id, int64 size, int os_error, | 124 void OnResponseCompleted(int32 download_id, int64 size, |
| 122 const std::string& hash); | 125 const std::string& hash); |
| 123 | 126 |
| 124 // Called from a view when a user clicks a UI button or link. | 127 // Called from a view when a user clicks a UI button or link. |
| 125 void DownloadCancelled(int32 download_id); | 128 void DownloadCancelled(int32 download_id); |
| 129 |
| 130 // Called when there is an error in the download. |
| 131 // |download_id| is the ID of the download. |
| 132 // |size| is the number of bytes that are currently downloaded. |
| 133 // |error| is a download error code. Indicates what caused the interruption. |
| 134 void OnDownloadError(int32 download_id, int64 size, int error); |
| 135 |
| 126 void RemoveDownload(int64 download_handle); | 136 void RemoveDownload(int64 download_handle); |
| 127 | 137 |
| 128 // Determine if the download is ready for completion, i.e. has had | 138 // Determine if the download is ready for completion, i.e. has had |
| 129 // all data saved, and completed the filename determination and | 139 // all data saved, and completed the filename determination and |
| 130 // history insertion. | 140 // history insertion. |
| 131 bool IsDownloadReadyForCompletion(DownloadItem* download); | 141 bool IsDownloadReadyForCompletion(DownloadItem* download); |
| 132 | 142 |
| 133 // If all pre-requisites have been met, complete download processing, i.e. | 143 // If all pre-requisites have been met, complete download processing, i.e. |
| 134 // do internal cleanup, file rename, and potentially auto-open. | 144 // do internal cleanup, file rename, and potentially auto-open. |
| 135 // (Dangerous downloads still may block on user acceptance after this | 145 // (Dangerous downloads still may block on user acceptance after this |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // Called back after a target path for the file to be downloaded to has been | 317 // Called back after a target path for the file to be downloaded to has been |
| 308 // determined, either automatically based on the suggested file name, or by | 318 // determined, either automatically based on the suggested file name, or by |
| 309 // the user in a Save As dialog box. | 319 // the user in a Save As dialog box. |
| 310 void ContinueDownloadWithPath(DownloadItem* download, | 320 void ContinueDownloadWithPath(DownloadItem* download, |
| 311 const FilePath& chosen_file); | 321 const FilePath& chosen_file); |
| 312 | 322 |
| 313 // Download cancel helper function. | 323 // Download cancel helper function. |
| 314 void DownloadCancelledInternal(int download_id, | 324 void DownloadCancelledInternal(int download_id, |
| 315 const DownloadRequestHandle& request_handle); | 325 const DownloadRequestHandle& request_handle); |
| 316 | 326 |
| 317 // All data has been downloaded. | 327 // Retrieves the download from the |download_id|. |
| 318 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 328 // Returns NULL if the download is not active. |
| 319 // is not available. | 329 DownloadItem* GetActiveDownload(int32 download_id); |
| 320 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); | |
| 321 | 330 |
| 322 // An error occurred in the download. | 331 // Removes |download| from the active and in progress maps. |
| 323 void OnDownloadError(int32 download_id, int64 size, int os_error); | 332 // Called when the download is cancelled or has an error. |
| 333 // Does nothing if the download is not in the history DB. |
| 334 void RemoveFromActiveList(DownloadItem* download); |
| 324 | 335 |
| 325 // Updates the delegate about the overall download progress. | 336 // Updates the delegate about the overall download progress. |
| 326 void UpdateDownloadProgress(); | 337 void UpdateDownloadProgress(); |
| 327 | 338 |
| 328 // Inform observers that the model has changed. | 339 // Inform observers that the model has changed. |
| 329 void NotifyModelChanged(); | 340 void NotifyModelChanged(); |
| 330 | 341 |
| 331 // Debugging routine to confirm relationship between below | 342 // Debugging routine to confirm relationship between below |
| 332 // containers; no-op if NDEBUG. | 343 // containers; no-op if NDEBUG. |
| 333 void AssertContainersConsistent() const; | 344 void AssertContainersConsistent() const; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 420 |
| 410 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 421 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
| 411 | 422 |
| 412 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 423 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
| 413 DownloadManagerDelegate* delegate_; | 424 DownloadManagerDelegate* delegate_; |
| 414 | 425 |
| 415 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 426 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 416 }; | 427 }; |
| 417 | 428 |
| 418 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 429 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |