| 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: |
| 11 // DownloadItem::Observer: | 11 // DownloadItem::Observer: |
| 12 // - allows observers to receive notifications about one download from start | 12 // - allows observers to receive notifications about one download from start |
| 13 // to completion | 13 // to completion |
| 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to | 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to |
| 15 // receive state updates. | 15 // receive state updates. |
| 16 | 16 |
| 17 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 17 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| 18 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 18 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| 19 #pragma once | 19 #pragma once |
| 20 | 20 |
| 21 #include <string> | 21 #include <string> |
| 22 | 22 |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 #include "base/file_path.h" | 24 #include "base/file_path.h" |
| 25 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 26 #include "base/time.h" | 26 #include "base/time.h" |
| 27 #include "base/timer.h" | 27 #include "base/timer.h" |
| 28 #include "chrome/browser/download/download_process_handle.h" |
| 28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 29 | 30 |
| 30 class DownloadFileManager; | 31 class DownloadFileManager; |
| 31 class DownloadManager; | 32 class DownloadManager; |
| 32 struct DownloadCreateInfo; | 33 struct DownloadCreateInfo; |
| 33 | 34 |
| 34 // One DownloadItem per download. This is the model class that stores all the | 35 // 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 | 36 // 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. | 37 // Destination tab's download view, may refer to a given DownloadItem. |
| 37 // | 38 // |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 int64 total_bytes() const { return total_bytes_; } | 254 int64 total_bytes() const { return total_bytes_; } |
| 254 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; } | 255 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; } |
| 255 int64 received_bytes() const { return received_bytes_; } | 256 int64 received_bytes() const { return received_bytes_; } |
| 256 int32 id() const { return id_; } | 257 int32 id() const { return id_; } |
| 257 base::Time start_time() const { return start_time_; } | 258 base::Time start_time() const { return start_time_; } |
| 258 void set_db_handle(int64 handle) { db_handle_ = handle; } | 259 void set_db_handle(int64 handle) { db_handle_ = handle; } |
| 259 int64 db_handle() const { return db_handle_; } | 260 int64 db_handle() const { return db_handle_; } |
| 260 bool is_paused() const { return is_paused_; } | 261 bool is_paused() const { return is_paused_; } |
| 261 bool open_when_complete() const { return open_when_complete_; } | 262 bool open_when_complete() const { return open_when_complete_; } |
| 262 void set_open_when_complete(bool open) { open_when_complete_ = open; } | 263 void set_open_when_complete(bool open) { open_when_complete_ = open; } |
| 263 int render_process_id() const { return render_process_id_; } | |
| 264 int request_id() const { return request_id_; } | |
| 265 SafetyState safety_state() const { return safety_state_; } | 264 SafetyState safety_state() const { return safety_state_; } |
| 266 void set_safety_state(SafetyState safety_state) { | 265 void set_safety_state(SafetyState safety_state) { |
| 267 safety_state_ = safety_state; | 266 safety_state_ = safety_state; |
| 268 } | 267 } |
| 269 DangerType danger_type() { return danger_type_;} | 268 DangerType danger_type() { return danger_type_;} |
| 270 bool auto_opened() { return auto_opened_; } | 269 bool auto_opened() { return auto_opened_; } |
| 271 FilePath target_name() const { return target_name_; } | 270 FilePath target_name() const { return target_name_; } |
| 272 bool save_as() const { return save_as_; } | 271 bool save_as() const { return save_as_; } |
| 273 bool is_otr() const { return is_otr_; } | 272 bool is_otr() const { return is_otr_; } |
| 274 bool is_extension_install() const { return is_extension_install_; } | 273 bool is_extension_install() const { return is_extension_install_; } |
| 275 bool name_finalized() const { return name_finalized_; } | 274 bool name_finalized() const { return name_finalized_; } |
| 276 bool is_temporary() const { return is_temporary_; } | 275 bool is_temporary() const { return is_temporary_; } |
| 277 void set_opened(bool opened) { opened_ = opened; } | 276 void set_opened(bool opened) { opened_ = opened; } |
| 278 bool opened() const { return opened_; } | 277 bool opened() const { return opened_; } |
| 279 | 278 |
| 279 const DownloadProcessHandle& process_handle() const { |
| 280 return process_handle_; |
| 281 } |
| 282 |
| 280 // Returns the final target file path for the download. | 283 // Returns the final target file path for the download. |
| 281 FilePath GetTargetFilePath() const; | 284 FilePath GetTargetFilePath() const; |
| 282 | 285 |
| 283 // Returns the file-name that should be reported to the user, which is | 286 // Returns the file-name that should be reported to the user, which is |
| 284 // target_name_ possibly with the uniquifier number. | 287 // target_name_ possibly with the uniquifier number. |
| 285 FilePath GetFileNameToReportUser() const; | 288 FilePath GetFileNameToReportUser() const; |
| 286 | 289 |
| 287 // Returns the user-verified target file path for the download. | 290 // Returns the user-verified target file path for the download. |
| 288 // This returns the same path as GetTargetFilePath() for safe downloads | 291 // This returns the same path as GetTargetFilePath() for safe downloads |
| 289 // but does not for dangerous downloads until the name is verified. | 292 // but does not for dangerous downloads until the name is verified. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // 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 |
| 380 // 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 |
| 381 // before the observer is added. | 384 // before the observer is added. |
| 382 bool auto_opened_; | 385 bool auto_opened_; |
| 383 | 386 |
| 384 // Dangerous downloads or ongoing downloads are given temporary names until | 387 // Dangerous downloads or ongoing downloads are given temporary names until |
| 385 // the user approves them or the downloads finish. | 388 // the user approves them or the downloads finish. |
| 386 // This stores their final target name. | 389 // This stores their final target name. |
| 387 FilePath target_name_; | 390 FilePath target_name_; |
| 388 | 391 |
| 389 // For canceling or pausing requests. | 392 // The handle to the process information. Used for operations outside the |
| 390 int render_process_id_; | 393 // download system. |
| 391 int request_id_; | 394 DownloadProcessHandle process_handle_; |
| 392 | 395 |
| 393 // True if the item was downloaded as a result of 'save as...' | 396 // True if the item was downloaded as a result of 'save as...' |
| 394 bool save_as_; | 397 bool save_as_; |
| 395 | 398 |
| 396 // True if the download was initiated in an incognito window. | 399 // True if the download was initiated in an incognito window. |
| 397 bool is_otr_; | 400 bool is_otr_; |
| 398 | 401 |
| 399 // True if the item was downloaded for an extension installation. | 402 // True if the item was downloaded for an extension installation. |
| 400 bool is_extension_install_; | 403 bool is_extension_install_; |
| 401 | 404 |
| 402 // True if the filename is finalized. | 405 // True if the filename is finalized. |
| 403 bool name_finalized_; | 406 bool name_finalized_; |
| 404 | 407 |
| 405 // True if the item was downloaded temporarily. | 408 // True if the item was downloaded temporarily. |
| 406 bool is_temporary_; | 409 bool is_temporary_; |
| 407 | 410 |
| 408 // True if we've saved all the data for the download. | 411 // True if we've saved all the data for the download. |
| 409 bool all_data_saved_; | 412 bool all_data_saved_; |
| 410 | 413 |
| 411 // 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 |
| 412 // 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 |
| 413 // 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 |
| 414 // be treated as though the user opened it. | 417 // be treated as though the user opened it. |
| 415 bool opened_; | 418 bool opened_; |
| 416 | 419 |
| 417 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 420 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 418 }; | 421 }; |
| 419 | 422 |
| 420 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 423 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |