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