| 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 13 matching lines...) Expand all Loading... |
| 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 "content/browser/download/download_request_handle.h" | 28 #include "content/browser/download/download_request_handle.h" |
| 29 #include "content/browser/download/download_state_info.h" | 29 #include "content/browser/download/download_state_info.h" |
| 30 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 31 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 32 | 32 |
| 33 class DownloadFileManager; | 33 class DownloadFileManager; |
| 34 class DownloadId; |
| 34 class DownloadManager; | 35 class DownloadManager; |
| 35 struct DownloadCreateInfo; | 36 struct DownloadCreateInfo; |
| 36 struct DownloadPersistentStoreInfo; | 37 struct DownloadPersistentStoreInfo; |
| 37 | 38 |
| 38 // One DownloadItem per download. This is the model class that stores all the | 39 // One DownloadItem per download. This is the model class that stores all the |
| 39 // state for a download. Multiple views, such as a tab's download shelf and the | 40 // state for a download. Multiple views, such as a tab's download shelf and the |
| 40 // Destination tab's download view, may refer to a given DownloadItem. | 41 // Destination tab's download view, may refer to a given DownloadItem. |
| 41 // | 42 // |
| 42 // This is intended to be used only on the UI thread. | 43 // This is intended to be used only on the UI thread. |
| 43 class DownloadItem { | 44 class DownloadItem { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Constructing for a regular download: | 117 // Constructing for a regular download: |
| 117 DownloadItem(DownloadManager* download_manager, | 118 DownloadItem(DownloadManager* download_manager, |
| 118 const DownloadCreateInfo& info, | 119 const DownloadCreateInfo& info, |
| 119 bool is_otr); | 120 bool is_otr); |
| 120 | 121 |
| 121 // Constructing for the "Save Page As..." feature: | 122 // Constructing for the "Save Page As..." feature: |
| 122 DownloadItem(DownloadManager* download_manager, | 123 DownloadItem(DownloadManager* download_manager, |
| 123 const FilePath& path, | 124 const FilePath& path, |
| 124 const GURL& url, | 125 const GURL& url, |
| 125 bool is_otr, | 126 bool is_otr, |
| 126 int download_id); | 127 DownloadId download_id); |
| 127 | 128 |
| 128 virtual ~DownloadItem(); | 129 virtual ~DownloadItem(); |
| 129 | 130 |
| 130 void AddObserver(Observer* observer); | 131 void AddObserver(Observer* observer); |
| 131 void RemoveObserver(Observer* observer); | 132 void RemoveObserver(Observer* observer); |
| 132 | 133 |
| 133 // Notifies our observers periodically. | 134 // Notifies our observers periodically. |
| 134 void UpdateObservers(); | 135 void UpdateObservers(); |
| 135 | 136 |
| 136 // Returns true if it is OK to open a folder which this file is inside. | 137 // Returns true if it is OK to open a folder which this file is inside. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 std::string content_disposition() const { return content_disposition_; } | 268 std::string content_disposition() const { return content_disposition_; } |
| 268 std::string mime_type() const { return mime_type_; } | 269 std::string mime_type() const { return mime_type_; } |
| 269 std::string original_mime_type() const { return original_mime_type_; } | 270 std::string original_mime_type() const { return original_mime_type_; } |
| 270 std::string referrer_charset() const { return referrer_charset_; } | 271 std::string referrer_charset() const { return referrer_charset_; } |
| 271 int64 total_bytes() const { return total_bytes_; } | 272 int64 total_bytes() const { return total_bytes_; } |
| 272 void set_total_bytes(int64 total_bytes) { | 273 void set_total_bytes(int64 total_bytes) { |
| 273 total_bytes_ = total_bytes; | 274 total_bytes_ = total_bytes; |
| 274 } | 275 } |
| 275 int64 received_bytes() const { return received_bytes_; } | 276 int64 received_bytes() const { return received_bytes_; } |
| 276 int32 id() const { return download_id_; } | 277 int32 id() const { return download_id_; } |
| 278 DownloadId global_id() const; |
| 277 base::Time start_time() const { return start_time_; } | 279 base::Time start_time() const { return start_time_; } |
| 278 void set_db_handle(int64 handle) { db_handle_ = handle; } | 280 void set_db_handle(int64 handle) { db_handle_ = handle; } |
| 279 int64 db_handle() const { return db_handle_; } | 281 int64 db_handle() const { return db_handle_; } |
| 280 DownloadManager* download_manager() { return download_manager_; } | 282 DownloadManager* download_manager() { return download_manager_; } |
| 281 bool is_paused() const { return is_paused_; } | 283 bool is_paused() const { return is_paused_; } |
| 282 bool open_when_complete() const { return open_when_complete_; } | 284 bool open_when_complete() const { return open_when_complete_; } |
| 283 void set_open_when_complete(bool open) { open_when_complete_ = open; } | 285 void set_open_when_complete(bool open) { open_when_complete_ = open; } |
| 284 bool file_externally_removed() const { return file_externally_removed_; } | 286 bool file_externally_removed() const { return file_externally_removed_; } |
| 285 SafetyState safety_state() const { return safety_state_; } | 287 SafetyState safety_state() const { return safety_state_; } |
| 286 // Why |safety_state_| is not SAFE. | 288 // Why |safety_state_| is not SAFE. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // only. | 478 // only. |
| 477 bool open_enabled_; | 479 bool open_enabled_; |
| 478 | 480 |
| 479 // Did the delegate delay calling Complete on this download? | 481 // Did the delegate delay calling Complete on this download? |
| 480 bool delegate_delayed_complete_; | 482 bool delegate_delayed_complete_; |
| 481 | 483 |
| 482 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 484 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
| 483 }; | 485 }; |
| 484 | 486 |
| 485 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 487 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |