Chromium Code Reviews| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 // exit (DownloadManager destructor) from user interface initiated cancels | 149 // exit (DownloadManager destructor) from user interface initiated cancels |
| 150 // because at exit, the history system may not exist, and any updates to it | 150 // because at exit, the history system may not exist, and any updates to it |
| 151 // require AddRef'ing the DownloadManager in the destructor which results in | 151 // require AddRef'ing the DownloadManager in the destructor which results in |
| 152 // a DCHECK failure. Set 'update_history' to false when canceling from at | 152 // a DCHECK failure. Set 'update_history' to false when canceling from at |
| 153 // exit to prevent this crash. This may result in a difference between the | 153 // exit to prevent this crash. This may result in a difference between the |
| 154 // downloaded file's size on disk, and what the history system's last record | 154 // downloaded file's size on disk, and what the history system's last record |
| 155 // of it is. At worst, we'll end up re-downloading a small portion of the file | 155 // of it is. At worst, we'll end up re-downloading a small portion of the file |
| 156 // when resuming a download (assuming the server supports byte ranges). | 156 // when resuming a download (assuming the server supports byte ranges). |
| 157 void Cancel(bool update_history); | 157 void Cancel(bool update_history); |
| 158 | 158 |
| 159 // Called when all data has been saved. Only has display effects. | |
| 160 void OnAllDataSaved(int64 size); | |
| 161 | |
| 162 // Called by external code (SavePackage) using the DownloadItem interface | 159 // Called by external code (SavePackage) using the DownloadItem interface |
| 163 // to display progress when the DownloadItem should be considered complete. | 160 // to display progress when the DownloadItem should be considered complete. |
| 164 void MarkAsComplete(); | 161 void MarkAsComplete(); |
| 165 | 162 |
| 163 // Called when all data has been saved. Only has display effects. | |
| 164 void OnAllDataSaved(int64 size); | |
| 165 | |
| 166 // Called when the downloaded file is removed. | |
| 167 void OnDownloadedFileRemoved(); | |
| 168 | |
| 166 // Download operation had an error. | 169 // Download operation had an error. |
| 167 // |size| is the amount of data received so far, and |os_error| is the error | 170 // |size| is the amount of data received so far, and |os_error| is the error |
| 168 // code that the operation received. | 171 // code that the operation received. |
| 169 void Interrupted(int64 size, int os_error); | 172 void Interrupted(int64 size, int os_error); |
| 170 | 173 |
| 171 // Deletes the file from disk and removes the download from the views and | 174 // Deletes the file from disk and removes the download from the views and |
| 172 // history. |user| should be true if this is the result of the user clicking | 175 // history. |user| should be true if this is the result of the user clicking |
| 173 // the discard button, and false if it is being deleted for other reasons like | 176 // the discard button, and false if it is being deleted for other reasons like |
| 174 // browser shutdown. | 177 // browser shutdown. |
| 175 void Delete(DeleteReason reason); | 178 void Delete(DeleteReason reason); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 int64 received_bytes() const { return received_bytes_; } | 255 int64 received_bytes() const { return received_bytes_; } |
| 253 int32 id() const { return id_; } | 256 int32 id() const { return id_; } |
| 254 base::Time start_time() const { return start_time_; } | 257 base::Time start_time() const { return start_time_; } |
| 255 void set_db_handle(int64 handle) { db_handle_ = handle; } | 258 void set_db_handle(int64 handle) { db_handle_ = handle; } |
| 256 int64 db_handle() const { return db_handle_; } | 259 int64 db_handle() const { return db_handle_; } |
| 257 bool is_paused() const { return is_paused_; } | 260 bool is_paused() const { return is_paused_; } |
| 258 bool open_when_complete() const { return open_when_complete_; } | 261 bool open_when_complete() const { return open_when_complete_; } |
| 259 void set_open_when_complete(bool open) { open_when_complete_ = open; } | 262 void set_open_when_complete(bool open) { open_when_complete_ = open; } |
| 260 int render_process_id() const { return render_process_id_; } | 263 int render_process_id() const { return render_process_id_; } |
| 261 int request_id() const { return request_id_; } | 264 int request_id() const { return request_id_; } |
| 265 bool file_exists() const { return file_exists_; } | |
| 262 SafetyState safety_state() const { return safety_state_; } | 266 SafetyState safety_state() const { return safety_state_; } |
| 263 void set_safety_state(SafetyState safety_state) { | 267 void set_safety_state(SafetyState safety_state) { |
| 264 safety_state_ = safety_state; | 268 safety_state_ = safety_state; |
| 265 } | 269 } |
| 266 DangerType danger_type() { return danger_type_;} | 270 DangerType danger_type() { return danger_type_;} |
| 267 bool auto_opened() { return auto_opened_; } | 271 bool auto_opened() { return auto_opened_; } |
| 268 FilePath target_name() const { return target_name_; } | 272 FilePath target_name() const { return target_name_; } |
| 269 bool save_as() const { return save_as_; } | 273 bool save_as() const { return save_as_; } |
| 270 bool is_otr() const { return is_otr_; } | 274 bool is_otr() const { return is_otr_; } |
| 271 bool is_extension_install() const { return is_extension_install_; } | 275 bool is_extension_install() const { return is_extension_install_; } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 362 |
| 359 // Our owning object | 363 // Our owning object |
| 360 DownloadManager* download_manager_; | 364 DownloadManager* download_manager_; |
| 361 | 365 |
| 362 // In progress downloads may be paused by the user, we note it here | 366 // In progress downloads may be paused by the user, we note it here |
| 363 bool is_paused_; | 367 bool is_paused_; |
| 364 | 368 |
| 365 // A flag for indicating if the download should be opened at completion. | 369 // A flag for indicating if the download should be opened at completion. |
| 366 bool open_when_complete_; | 370 bool open_when_complete_; |
| 367 | 371 |
| 372 // A flag for indicating if the downloaded file exists. | |
| 373 bool file_exists_; | |
|
Randy Smith (Not in Mondays)
2011/05/12 20:21:17
This flag is currently only valid after the state
Paweł Hajdan Jr.
2011/05/13 08:41:10
I prefer file_exists for simplicity. file_external
haraken1
2011/05/13 14:08:17
I also prefer |file_externally_removed_| in this c
Randy Smith (Not in Mondays)
2011/05/13 20:45:32
Sure, but having a race condition to watch for bet
| |
| 374 | |
| 368 // Whether the download is considered potentially safe or dangerous | 375 // Whether the download is considered potentially safe or dangerous |
| 369 // (executable files are typically considered dangerous). | 376 // (executable files are typically considered dangerous). |
| 370 SafetyState safety_state_; | 377 SafetyState safety_state_; |
| 371 | 378 |
| 372 // Why |safety_state_| is not SAFE. | 379 // Why |safety_state_| is not SAFE. |
| 373 DangerType danger_type_; | 380 DangerType danger_type_; |
| 374 | 381 |
| 375 // Whether the download was auto-opened. We set this rather than using | 382 // Whether the download was auto-opened. We set this rather than using |
| 376 // an observer as it's frequently possible for the download to be auto opened | 383 // an observer as it's frequently possible for the download to be auto opened |
| 377 // before the observer is added. | 384 // before the observer is added. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 404 // Did the user open the item either directly or indirectly (such as by | 411 // Did the user open the item either directly or indirectly (such as by |
| 405 // setting always open files of this type)? The shelf also sets this field | 412 // setting always open files of this type)? The shelf also sets this field |
| 406 // when the user closes the shelf before the item has been opened but should | 413 // when the user closes the shelf before the item has been opened but should |
| 407 // be treated as though the user opened it. | 414 // be treated as though the user opened it. |
| 408 bool opened_; | 415 bool opened_; |
| 409 | 416 |
| 410 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 417 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 411 }; | 418 }; |
| 412 | 419 |
| 413 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 420 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |