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 #include <iostream> | |
22 | 23 |
23 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
24 #include "base/file_path.h" | 25 #include "base/file_path.h" |
25 #include "base/observer_list.h" | 26 #include "base/observer_list.h" |
26 #include "base/time.h" | 27 #include "base/time.h" |
27 #include "base/timer.h" | 28 #include "base/timer.h" |
28 #include "chrome/browser/download/download_request_handle.h" | 29 #include "chrome/browser/download/download_request_handle.h" |
29 #include "chrome/browser/download/download_state_info.h" | 30 #include "chrome/browser/download/download_state_info.h" |
30 #include "content/common/notification_observer.h" | 31 #include "content/common/notification_observer.h" |
31 #include "content/common/notification_registrar.h" | 32 #include "content/common/notification_registrar.h" |
32 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
33 | 34 |
34 class CrxInstaller; | 35 class CrxInstaller; |
35 class DownloadFileManager; | 36 class DownloadFileManager; |
37 class DownloadId; | |
36 class DownloadManager; | 38 class DownloadManager; |
37 struct DownloadCreateInfo; | 39 struct DownloadCreateInfo; |
38 struct DownloadHistoryInfo; | 40 struct DownloadHistoryInfo; |
39 | 41 |
40 // One DownloadItem per download. This is the model class that stores all the | 42 // One DownloadItem per download. This is the model class that stores all the |
41 // state for a download. Multiple views, such as a tab's download shelf and the | 43 // state for a download. Multiple views, such as a tab's download shelf and the |
42 // Destination tab's download view, may refer to a given DownloadItem. | 44 // Destination tab's download view, may refer to a given DownloadItem. |
43 // | 45 // |
44 // This is intended to be used only on the UI thread. | 46 // This is intended to be used only on the UI thread. |
45 class DownloadItem : public NotificationObserver { | 47 class DownloadItem : public NotificationObserver { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 std::string content_disposition() const { return content_disposition_; } | 272 std::string content_disposition() const { return content_disposition_; } |
271 std::string mime_type() const { return mime_type_; } | 273 std::string mime_type() const { return mime_type_; } |
272 std::string original_mime_type() const { return original_mime_type_; } | 274 std::string original_mime_type() const { return original_mime_type_; } |
273 std::string referrer_charset() const { return referrer_charset_; } | 275 std::string referrer_charset() const { return referrer_charset_; } |
274 int64 total_bytes() const { return total_bytes_; } | 276 int64 total_bytes() const { return total_bytes_; } |
275 void set_total_bytes(int64 total_bytes) { | 277 void set_total_bytes(int64 total_bytes) { |
276 total_bytes_ = total_bytes; | 278 total_bytes_ = total_bytes; |
277 } | 279 } |
278 int64 received_bytes() const { return received_bytes_; } | 280 int64 received_bytes() const { return received_bytes_; } |
279 int32 id() const { return download_id_; } | 281 int32 id() const { return download_id_; } |
282 DownloadId gid() const; | |
Randy Smith (Not in Mondays)
2011/07/28 21:03:16
I'd be inclined to call this global_id(); that's w
benjhayden
2011/08/03 17:44:46
Done.
| |
280 base::Time start_time() const { return start_time_; } | 283 base::Time start_time() const { return start_time_; } |
281 void set_db_handle(int64 handle) { db_handle_ = handle; } | 284 void set_db_handle(int64 handle) { db_handle_ = handle; } |
282 int64 db_handle() const { return db_handle_; } | 285 int64 db_handle() const { return db_handle_; } |
283 bool is_paused() const { return is_paused_; } | 286 bool is_paused() const { return is_paused_; } |
284 bool open_when_complete() const { return open_when_complete_; } | 287 bool open_when_complete() const { return open_when_complete_; } |
285 void set_open_when_complete(bool open) { open_when_complete_ = open; } | 288 void set_open_when_complete(bool open) { open_when_complete_ = open; } |
286 bool file_externally_removed() const { return file_externally_removed_; } | 289 bool file_externally_removed() const { return file_externally_removed_; } |
287 SafetyState safety_state() const { return safety_state_; } | 290 SafetyState safety_state() const { return safety_state_; } |
288 // Why |safety_state_| is not SAFE. | 291 // Why |safety_state_| is not SAFE. |
289 DangerType GetDangerType() const; | 292 DangerType GetDangerType() const; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 | 483 |
481 // Do we actual open downloads when requested? For testing purposes | 484 // Do we actual open downloads when requested? For testing purposes |
482 // only. | 485 // only. |
483 bool open_enabled_; | 486 bool open_enabled_; |
484 | 487 |
485 // DownloadItem observes CRX installs it initiates. | 488 // DownloadItem observes CRX installs it initiates. |
486 NotificationRegistrar registrar_; | 489 NotificationRegistrar registrar_; |
487 | 490 |
488 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 491 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
489 }; | 492 }; |
490 | |
491 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 493 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
OLD | NEW |