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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 18 #define CONTENT_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 "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 "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
32 | 33 |
33 class DownloadFileManager; | 34 class DownloadFileManager; |
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 CONTENT_EXPORT DownloadItem { |
44 public: | 45 public: |
45 enum DownloadState { | 46 enum DownloadState { |
46 // Download is actively progressing. | 47 // Download is actively progressing. |
47 IN_PROGRESS = 0, | 48 IN_PROGRESS = 0, |
48 | 49 |
49 // Download is completely finished. | 50 // Download is completely finished. |
50 COMPLETE, | 51 COMPLETE, |
51 | 52 |
52 // Download has been cancelled. | 53 // Download has been cancelled. |
53 CANCELLED, | 54 CANCELLED, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, | 92 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, |
92 DELETE_DUE_TO_USER_DISCARD | 93 DELETE_DUE_TO_USER_DISCARD |
93 }; | 94 }; |
94 | 95 |
95 // A fake download table ID which represents a download that has started, | 96 // A fake download table ID which represents a download that has started, |
96 // but is not yet in the table. | 97 // but is not yet in the table. |
97 static const int kUninitializedHandle; | 98 static const int kUninitializedHandle; |
98 | 99 |
99 // Interface that observers of a particular download must implement in order | 100 // Interface that observers of a particular download must implement in order |
100 // to receive updates to the download's status. | 101 // to receive updates to the download's status. |
101 class Observer { | 102 class CONTENT_EXPORT Observer { |
102 public: | 103 public: |
103 virtual void OnDownloadUpdated(DownloadItem* download) = 0; | 104 virtual void OnDownloadUpdated(DownloadItem* download) = 0; |
104 | 105 |
105 // Called when a downloaded file has been opened. | 106 // Called when a downloaded file has been opened. |
106 virtual void OnDownloadOpened(DownloadItem* download) = 0; | 107 virtual void OnDownloadOpened(DownloadItem* download) = 0; |
107 | 108 |
108 protected: | 109 protected: |
109 virtual ~Observer() {} | 110 virtual ~Observer() {} |
110 }; | 111 }; |
111 | 112 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // only. | 477 // only. |
477 bool open_enabled_; | 478 bool open_enabled_; |
478 | 479 |
479 // Did the delegate delay calling Complete on this download? | 480 // Did the delegate delay calling Complete on this download? |
480 bool delegate_delayed_complete_; | 481 bool delegate_delayed_complete_; |
481 | 482 |
482 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 483 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
483 }; | 484 }; |
484 | 485 |
485 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 486 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
OLD | NEW |