OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 enum DownloadState { | 55 enum DownloadState { |
56 // Download is actively progressing. | 56 // Download is actively progressing. |
57 IN_PROGRESS = 0, | 57 IN_PROGRESS = 0, |
58 | 58 |
59 // Download is completely finished. | 59 // Download is completely finished. |
60 COMPLETE, | 60 COMPLETE, |
61 | 61 |
62 // Download has been cancelled. | 62 // Download has been cancelled. |
63 CANCELLED, | 63 CANCELLED, |
64 | 64 |
65 // This state indicates that the download item is about to be destroyed, | |
66 // and observers seeing this state should release all references. | |
67 REMOVING, | |
68 | |
69 // This state indicates that the download has been interrupted. | 65 // This state indicates that the download has been interrupted. |
70 INTERRUPTED, | 66 INTERRUPTED, |
71 | 67 |
72 // Maximum value. | 68 // Maximum value. |
73 MAX_DOWNLOAD_STATE | 69 MAX_DOWNLOAD_STATE |
74 }; | 70 }; |
75 | 71 |
76 enum SafetyState { | 72 enum SafetyState { |
77 SAFE = 0, | 73 SAFE = 0, |
78 DANGEROUS, | 74 DANGEROUS, |
(...skipping 17 matching lines...) Expand all Loading... | |
96 // A fake download table ID which represents a download that has started, | 92 // A fake download table ID which represents a download that has started, |
97 // but is not yet in the table. | 93 // but is not yet in the table. |
98 static const int kUninitializedHandle; | 94 static const int kUninitializedHandle; |
99 | 95 |
100 static const char kEmptyFileHash[]; | 96 static const char kEmptyFileHash[]; |
101 | 97 |
102 // Interface that observers of a particular download must implement in order | 98 // Interface that observers of a particular download must implement in order |
103 // to receive updates to the download's status. | 99 // to receive updates to the download's status. |
104 class CONTENT_EXPORT Observer { | 100 class CONTENT_EXPORT Observer { |
105 public: | 101 public: |
106 virtual void OnDownloadUpdated(DownloadItem* download) = 0; | 102 virtual void OnDownloadUpdated(DownloadItem* download) {} |
107 | 103 |
108 // Called when a downloaded file has been opened. | 104 // Called when a downloaded file has been opened. |
109 virtual void OnDownloadOpened(DownloadItem* download) = 0; | 105 virtual void OnDownloadOpened(DownloadItem* download) {} |
106 | |
107 // Called when the user removed the download from history. | |
Randy Smith (Not in Mondays)
2012/07/14 19:25:53
nit: The action is the user removing the download
benjhayden
2012/07/23 15:43:09
Done.
| |
108 virtual void OnDownloadRemoved(DownloadItem* download) {} | |
109 | |
110 // Called when the download is being destroyed. This happens after | |
111 // every OnDownloadRemoved() as well as when the DownloadManager is going | |
112 // down. | |
113 virtual void OnDownloadDestroyed(DownloadItem* download) {} | |
110 | 114 |
111 protected: | 115 protected: |
112 virtual ~Observer() {} | 116 virtual ~Observer() {} |
113 }; | 117 }; |
114 | 118 |
115 // Interface for data that can be stored associated with (and owned | 119 // Interface for data that can be stored associated with (and owned |
116 // by) an object of this class via GetExternalData/SetExternalData. | 120 // by) an object of this class via GetExternalData/SetExternalData. |
117 class ExternalData { | 121 class ExternalData { |
118 public: | 122 public: |
119 virtual ~ExternalData() {}; | 123 virtual ~ExternalData() {}; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 virtual void SetExternalData(const void* key, ExternalData* data) = 0; | 370 virtual void SetExternalData(const void* key, ExternalData* data) = 0; |
367 | 371 |
368 virtual std::string DebugString(bool verbose) const = 0; | 372 virtual std::string DebugString(bool verbose) const = 0; |
369 | 373 |
370 virtual void MockDownloadOpenForTesting() = 0; | 374 virtual void MockDownloadOpenForTesting() = 0; |
371 }; | 375 }; |
372 | 376 |
373 } // namespace content | 377 } // namespace content |
374 | 378 |
375 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 379 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |