| 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 "chrome/browser/download/download_request_handle.h" |
| 29 #include "chrome/browser/download/download_state_info.h" | 29 #include "chrome/browser/download/download_state_info.h" |
| 30 #include "content/common/notification_observer.h" | 30 #include "content/common/notification_observer.h" |
| 31 #include "content/common/notification_registrar.h" | 31 #include "content/common/notification_registrar.h" |
| 32 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
| 33 | 33 |
| 34 class CrxInstaller; | 34 class CrxInstaller; |
| 35 class DownloadFileManager; | 35 class DownloadFileManager; |
| 36 class DownloadManager; | 36 class DownloadManager; |
| 37 struct DownloadCreateInfo; | 37 struct DownloadCreateInfo; |
| 38 struct DownloadHistoryInfo; | 38 struct DownloadHistoryInfo; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 bool is_extension_install() const { | 295 bool is_extension_install() const { |
| 296 return state_info_.is_extension_install; | 296 return state_info_.is_extension_install; |
| 297 } | 297 } |
| 298 FilePath suggested_path() const { return state_info_.suggested_path; } | 298 FilePath suggested_path() const { return state_info_.suggested_path; } |
| 299 bool is_temporary() const { return is_temporary_; } | 299 bool is_temporary() const { return is_temporary_; } |
| 300 void set_opened(bool opened) { opened_ = opened; } | 300 void set_opened(bool opened) { opened_ = opened; } |
| 301 bool opened() const { return opened_; } | 301 bool opened() const { return opened_; } |
| 302 | 302 |
| 303 DownloadHistoryInfo GetHistoryInfo() const; | 303 DownloadHistoryInfo GetHistoryInfo() const; |
| 304 DownloadStateInfo state_info() const { return state_info_; } | 304 DownloadStateInfo state_info() const { return state_info_; } |
| 305 const DownloadProcessHandle& process_handle() const { | 305 const DownloadRequestHandle& request_handle() const { |
| 306 return process_handle_; | 306 return request_handle_; |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Returns the final target file path for the download. | 309 // Returns the final target file path for the download. |
| 310 FilePath GetTargetFilePath() const; | 310 FilePath GetTargetFilePath() const; |
| 311 | 311 |
| 312 // Returns the file-name that should be reported to the user, which is | 312 // Returns the file-name that should be reported to the user, which is |
| 313 // target_name possibly with the uniquifier number. | 313 // target_name possibly with the uniquifier number. |
| 314 FilePath GetFileNameToReportUser() const; | 314 FilePath GetFileNameToReportUser() const; |
| 315 | 315 |
| 316 // Returns the user-verified target file path for the download. | 316 // Returns the user-verified target file path for the download. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 void StartProgressTimer(); | 353 void StartProgressTimer(); |
| 354 void StopProgressTimer(); | 354 void StopProgressTimer(); |
| 355 | 355 |
| 356 // Call to install this item as a CRX. Should only be called on | 356 // Call to install this item as a CRX. Should only be called on |
| 357 // items which are CRXes. Use is_extension_install() to check. | 357 // items which are CRXes. Use is_extension_install() to check. |
| 358 void StartCrxInstall(); | 358 void StartCrxInstall(); |
| 359 | 359 |
| 360 // State information used by the download manager. | 360 // State information used by the download manager. |
| 361 DownloadStateInfo state_info_; | 361 DownloadStateInfo state_info_; |
| 362 | 362 |
| 363 // The handle to the process information. Used for operations outside the | 363 // The handle to the request information. Used for operations outside the |
| 364 // download system. | 364 // download system. |
| 365 DownloadProcessHandle process_handle_; | 365 DownloadRequestHandle request_handle_; |
| 366 | 366 |
| 367 // Download ID assigned by DownloadResourceHandler. | 367 // Download ID assigned by DownloadResourceHandler. |
| 368 int32 download_id_; | 368 int32 download_id_; |
| 369 | 369 |
| 370 // Full path to the downloaded or downloading file. | 370 // Full path to the downloaded or downloading file. |
| 371 FilePath full_path_; | 371 FilePath full_path_; |
| 372 | 372 |
| 373 // A number that should be appended to the path to make it unique, or 0 if the | 373 // A number that should be appended to the path to make it unique, or 0 if the |
| 374 // path should be used as is. | 374 // path should be used as is. |
| 375 int path_uniquifier_; | 375 int path_uniquifier_; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // only. | 460 // only. |
| 461 bool open_enabled_; | 461 bool open_enabled_; |
| 462 | 462 |
| 463 // DownloadItem observes CRX installs it initiates. | 463 // DownloadItem observes CRX installs it initiates. |
| 464 NotificationRegistrar registrar_; | 464 NotificationRegistrar registrar_; |
| 465 | 465 |
| 466 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 466 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 467 }; | 467 }; |
| 468 | 468 |
| 469 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 469 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |