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 are currently 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. | |
cbentzel
2011/08/16 15:50:36
that were downloaded at the time of the interrupti
ahendrickson
2011/08/18 21:52:01
Yes. Changed.
| |
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 // Called back after a target path for the file to be downloaded to has been | 344 // Called back after a target path for the file to be downloaded to has been |
335 // determined, either automatically based on the suggested file name, or by | 345 // determined, either automatically based on the suggested file name, or by |
336 // the user in a Save As dialog box. | 346 // the user in a Save As dialog box. |
337 void ContinueDownloadWithPath(DownloadItem* download, | 347 void ContinueDownloadWithPath(DownloadItem* download, |
338 const FilePath& chosen_file); | 348 const FilePath& chosen_file); |
339 | 349 |
340 // Download cancel helper function. | 350 // Download cancel helper function. |
341 void DownloadCancelledInternal(int download_id, | 351 void DownloadCancelledInternal(int download_id, |
342 const DownloadRequestHandle& request_handle); | 352 const DownloadRequestHandle& request_handle); |
343 | 353 |
344 // All data has been downloaded. | 354 // Retrieves the download from the |download_id|. |
345 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 355 // Returns NULL if the download is not active. |
346 // is not available. | 356 DownloadItem* GetActiveDownload(int32 download_id); |
347 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); | |
348 | 357 |
349 // An error occurred in the download. | 358 // Removes |download| from the active and in progress maps. |
350 void OnDownloadError(int32 download_id, int64 size, int os_error); | 359 // Called when the download is cancelled or has an error. |
360 // Does nothing if the download is not in the history DB. | |
361 void RemoveFromActiveList(DownloadItem* download); | |
351 | 362 |
352 // Updates the app icon about the overall download progress. | 363 // Updates the app icon about the overall download progress. |
353 void UpdateAppIcon(); | 364 void UpdateAppIcon(); |
354 | 365 |
355 // Inform observers that the model has changed. | 366 // Inform observers that the model has changed. |
356 void NotifyModelChanged(); | 367 void NotifyModelChanged(); |
357 | 368 |
358 // Get the download item from the active map. Useful when the item is not | 369 // Get the download item from the active map. Useful when the item is not |
359 // yet in the history map. | 370 // yet in the history map. |
360 DownloadItem* GetActiveDownloadItem(int id); | 371 DownloadItem* GetActiveDownloadItem(int id); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 | 451 |
441 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 452 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
442 | 453 |
443 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 454 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
444 DownloadManagerDelegate* delegate_; | 455 DownloadManagerDelegate* delegate_; |
445 | 456 |
446 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 457 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
447 }; | 458 }; |
448 | 459 |
449 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 460 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
OLD | NEW |