OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 // One DownloadItem per download. This is the model class that stores all the | 34 // One DownloadItem per download. This is the model class that stores all the |
35 // state for a download. Multiple views, such as a tab's download shelf and the | 35 // state for a download. Multiple views, such as a tab's download shelf and the |
36 // Destination tab's download view, may refer to a given DownloadItem. | 36 // Destination tab's download view, may refer to a given DownloadItem. |
37 // | 37 // |
38 // This is intended to be used only on the UI thread. | 38 // This is intended to be used only on the UI thread. |
39 class DownloadItem { | 39 class DownloadItem { |
40 public: | 40 public: |
41 enum DownloadState { | 41 enum DownloadState { |
42 IN_PROGRESS, | 42 IN_PROGRESS, |
43 | |
44 // Note that COMPLETE indicates that the download has gotten all of its | |
45 // data, has figured out its final destination file, has been entered | |
46 // into the history store, and has been shown in the UI. The only | |
47 // operations remaining are (possibly) acceptance by the user of | |
48 // a dangerous download, and renaming the file to the final name and | |
Paweł Hajdan Jr.
2011/01/17 18:13:24
nit: "and..." - is the later part of this comment
Randy Smith (Not in Mondays)
2011/01/18 22:32:46
Done.
| |
43 COMPLETE, | 49 COMPLETE, |
50 | |
44 CANCELLED, | 51 CANCELLED, |
52 | |
53 // This state indicates that the download item is about to be destroyed, | |
54 // and observers seeing this state should release all references. | |
45 REMOVING | 55 REMOVING |
46 }; | 56 }; |
47 | 57 |
48 enum SafetyState { | 58 enum SafetyState { |
49 SAFE = 0, | 59 SAFE = 0, |
50 DANGEROUS, | 60 DANGEROUS, |
51 DANGEROUS_BUT_VALIDATED // Dangerous but the user confirmed the download. | 61 DANGEROUS_BUT_VALIDATED // Dangerous but the user confirmed the download. |
52 }; | 62 }; |
53 | 63 |
54 // Interface that observers of a particular download must implement in order | 64 // Interface that observers of a particular download must implement in order |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 // because at exit, the history system may not exist, and any updates to it | 132 // because at exit, the history system may not exist, and any updates to it |
123 // require AddRef'ing the DownloadManager in the destructor which results in | 133 // require AddRef'ing the DownloadManager in the destructor which results in |
124 // a DCHECK failure. Set 'update_history' to false when canceling from at | 134 // a DCHECK failure. Set 'update_history' to false when canceling from at |
125 // exit to prevent this crash. This may result in a difference between the | 135 // exit to prevent this crash. This may result in a difference between the |
126 // downloaded file's size on disk, and what the history system's last record | 136 // downloaded file's size on disk, and what the history system's last record |
127 // of it is. At worst, we'll end up re-downloading a small portion of the file | 137 // of it is. At worst, we'll end up re-downloading a small portion of the file |
128 // when resuming a download (assuming the server supports byte ranges). | 138 // when resuming a download (assuming the server supports byte ranges). |
129 void Cancel(bool update_history); | 139 void Cancel(bool update_history); |
130 | 140 |
131 // Called when all data has been saved. | 141 // Called when all data has been saved. |
132 void OnAllDataSaved(int64 size); | 142 void OnReadyToFinish(int64 size); |
133 | 143 |
134 // Called when the entire download operation (including renaming etc) | 144 // Called when the entire download operation (including renaming etc) |
135 // is finished. | 145 // is finished. |
136 void Finished(); | 146 void Finished(); |
137 | 147 |
138 // The user wants to remove the download from the views and history. If | 148 // The user wants to remove the download from the views and history. If |
139 // |delete_file| is true, the file is deleted on the disk. | 149 // |delete_file| is true, the file is deleted on the disk. |
140 void Remove(bool delete_file); | 150 void Remove(bool delete_file); |
141 | 151 |
142 // Simple calculation of the amount of time remaining to completion. Fills | 152 // Simple calculation of the amount of time remaining to completion. Fills |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 // Did the user open the item either directly or indirectly (such as by | 348 // Did the user open the item either directly or indirectly (such as by |
339 // setting always open files of this type)? The shelf also sets this field | 349 // setting always open files of this type)? The shelf also sets this field |
340 // when the user closes the shelf before the item has been opened but should | 350 // when the user closes the shelf before the item has been opened but should |
341 // be treated as though the user opened it. | 351 // be treated as though the user opened it. |
342 bool opened_; | 352 bool opened_; |
343 | 353 |
344 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 354 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
345 }; | 355 }; |
346 | 356 |
347 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 357 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
OLD | NEW |