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