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 // Each download is represented by a DownloadItem, and all DownloadItems | 5 // Each download is represented by a DownloadItem, and all DownloadItems |
6 // are owned by the DownloadManager which maintains a global list of all | 6 // are owned by the DownloadManager which maintains a global list of all |
7 // downloads. DownloadItems are created when a user initiates a download, | 7 // downloads. DownloadItems are created when a user initiates a download, |
8 // and exist for the duration of the browser life time. | 8 // and exist for the duration of the browser life time. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // Show the download via the OS shell. | 151 // Show the download via the OS shell. |
152 void ShowDownloadInShell(); | 152 void ShowDownloadInShell(); |
153 | 153 |
154 // Called when the user has validated the download of a dangerous file. | 154 // Called when the user has validated the download of a dangerous file. |
155 void DangerousDownloadValidated(); | 155 void DangerousDownloadValidated(); |
156 | 156 |
157 // Received a new chunk of data | 157 // Received a new chunk of data |
158 void Update(int64 bytes_so_far); | 158 void Update(int64 bytes_so_far); |
159 | 159 |
160 // Cancel the download operation. This may be called at any time; if | 160 // Cancel the download operation. We need to distinguish between cancels at |
161 // it is called before all download attributes have been finalized and | 161 // exit (DownloadManager destructor) from user interface initiated cancels |
162 // the download entered into the history, it will remove the download from | 162 // because at exit, the history system may not exist, and any updates to it |
163 // the system. | 163 // require AddRef'ing the DownloadManager in the destructor which results in |
164 void Cancel(); | 164 // a DCHECK failure. Set 'update_history' to false when canceling from at |
| 165 // exit to prevent this crash. This may result in a difference between the |
| 166 // downloaded file's size on disk, and what the history system's last record |
| 167 // of it is. At worst, we'll end up re-downloading a small portion of the file |
| 168 // when resuming a download (assuming the server supports byte ranges). |
| 169 void Cancel(bool update_history); |
165 | 170 |
166 // Called by external code (SavePackage) using the DownloadItem interface | 171 // Called by external code (SavePackage) using the DownloadItem interface |
167 // to display progress when the DownloadItem should be considered complete. | 172 // to display progress when the DownloadItem should be considered complete. |
168 void MarkAsComplete(); | 173 void MarkAsComplete(); |
169 | 174 |
170 // Called by the delegate after it delayed completing the download in | 175 // Called by the delegate after it delayed completing the download in |
171 // DownloadManagerDelegate::ShouldCompleteDownload. | 176 // DownloadManagerDelegate::ShouldCompleteDownload. |
172 void CompleteDelayedDownload(); | 177 void CompleteDelayedDownload(); |
173 | 178 |
174 // Called when all data has been saved. Only has display effects. | 179 // Called when all data has been saved. Only has display effects. |
175 void OnAllDataSaved(int64 size); | 180 void OnAllDataSaved(int64 size); |
176 | 181 |
177 // Called when the downloaded file is removed. | 182 // Called when the downloaded file is removed. |
178 void OnDownloadedFileRemoved(); | 183 void OnDownloadedFileRemoved(); |
179 | 184 |
180 // Download operation had an error; call to interrupt the processing. | 185 // Download operation had an error. |
181 // Note that if the download attributes haven't yet been finalized and | 186 // |size| is the amount of data received at interruption. |
182 // the download entered into the history (which implies that it hasn't | 187 // |error| is the network error code that the operation received. |
183 // yet been made visible in the UI), this call will remove the | 188 void Interrupted(int64 size, net::Error error); |
184 // download from the system. | |
185 // |size| is the amount of data received so far, and |net_error| is the | |
186 // error code that the operation received. | |
187 void Interrupt(int64 size, net::Error net_error); | |
188 | 189 |
189 // Deletes the file from disk and removes the download from the views and | 190 // Deletes the file from disk and removes the download from the views and |
190 // history. |user| should be true if this is the result of the user clicking | 191 // history. |user| should be true if this is the result of the user clicking |
191 // the discard button, and false if it is being deleted for other reasons like | 192 // the discard button, and false if it is being deleted for other reasons like |
192 // browser shutdown. | 193 // browser shutdown. |
193 void Delete(DeleteReason reason); | 194 void Delete(DeleteReason reason); |
194 | 195 |
195 // Removes the download from the views and history. | 196 // Removes the download from the views and history. |
196 void Remove(); | 197 void Remove(); |
197 | 198 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 void UpdateSize(int64 size); | 350 void UpdateSize(int64 size); |
350 | 351 |
351 // Called when the entire download operation (including renaming etc) | 352 // Called when the entire download operation (including renaming etc) |
352 // is completed. | 353 // is completed. |
353 void Completed(); | 354 void Completed(); |
354 | 355 |
355 // Start/stop sending periodic updates to our observers | 356 // Start/stop sending periodic updates to our observers |
356 void StartProgressTimer(); | 357 void StartProgressTimer(); |
357 void StopProgressTimer(); | 358 void StopProgressTimer(); |
358 | 359 |
359 // Does the actual work of transition state; all state | 360 // Call to transition state; all state transitions should go through this. |
360 // transitions should go through this. | |
361 void TransitionTo(DownloadState new_state); | 361 void TransitionTo(DownloadState new_state); |
362 | 362 |
363 // Called when safety_state_ should be recomputed from is_dangerous_file | 363 // Called when safety_state_ should be recomputed from is_dangerous_file |
364 // and is_dangerous_url. | 364 // and is_dangerous_url. |
365 void UpdateSafetyState(); | 365 void UpdateSafetyState(); |
366 | 366 |
367 // Helper function to recompute |state_info_.target_name| when | 367 // Helper function to recompute |state_info_.target_name| when |
368 // it may have changed. (If it's non-null it should be left alone, | 368 // it may have changed. (If it's non-null it should be left alone, |
369 // otherwise updated from |full_path_|.) | 369 // otherwise updated from |full_path_|.) |
370 void UpdateTarget(); | 370 void UpdateTarget(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // only. | 479 // only. |
480 bool open_enabled_; | 480 bool open_enabled_; |
481 | 481 |
482 // Did the delegate delay calling Complete on this download? | 482 // Did the delegate delay calling Complete on this download? |
483 bool delegate_delayed_complete_; | 483 bool delegate_delayed_complete_; |
484 | 484 |
485 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 485 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
486 }; | 486 }; |
487 | 487 |
488 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 488 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
OLD | NEW |