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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 enum DownloadState { | 56 enum DownloadState { |
57 // Download is actively progressing. | 57 // Download is actively progressing. |
58 IN_PROGRESS = 0, | 58 IN_PROGRESS = 0, |
59 | 59 |
60 // Download is completely finished. | 60 // Download is completely finished. |
61 COMPLETE, | 61 COMPLETE, |
62 | 62 |
63 // Download has been cancelled. | 63 // Download has been cancelled. |
64 CANCELLED, | 64 CANCELLED, |
65 | 65 |
66 // This state indicates that the download item is about to be destroyed, | |
67 // and observers seeing this state should release all references. | |
68 REMOVING, | |
69 | |
70 // This state indicates that the download has been interrupted. | 66 // This state indicates that the download has been interrupted. |
71 INTERRUPTED, | 67 INTERRUPTED, |
72 | 68 |
73 // Maximum value. | 69 // Maximum value. |
74 MAX_DOWNLOAD_STATE | 70 MAX_DOWNLOAD_STATE |
75 }; | 71 }; |
76 | 72 |
77 enum SafetyState { | 73 enum SafetyState { |
78 SAFE = 0, | 74 SAFE = 0, |
79 DANGEROUS, | 75 DANGEROUS, |
(...skipping 19 matching lines...) Expand all Loading... |
99 // A fake download table ID which represents a download that has started, | 95 // A fake download table ID which represents a download that has started, |
100 // but is not yet in the table. | 96 // but is not yet in the table. |
101 static const int kUninitializedHandle; | 97 static const int kUninitializedHandle; |
102 | 98 |
103 static const char kEmptyFileHash[]; | 99 static const char kEmptyFileHash[]; |
104 | 100 |
105 // Interface that observers of a particular download must implement in order | 101 // Interface that observers of a particular download must implement in order |
106 // to receive updates to the download's status. | 102 // to receive updates to the download's status. |
107 class CONTENT_EXPORT Observer { | 103 class CONTENT_EXPORT Observer { |
108 public: | 104 public: |
109 virtual void OnDownloadUpdated(DownloadItem* download) = 0; | 105 virtual void OnDownloadUpdated(DownloadItem* download) {} |
110 | 106 |
111 // Called when a downloaded file has been opened. | 107 // Called when a downloaded file has been opened. |
112 virtual void OnDownloadOpened(DownloadItem* download) = 0; | 108 virtual void OnDownloadOpened(DownloadItem* download) {} |
| 109 |
| 110 // Called when the user removed the download either from UI or at shutdown. |
| 111 virtual void OnDownloadRemoved(DownloadItem* download) {} |
| 112 |
| 113 // Called when the download is being destroyed. This happens after |
| 114 // every OnDownloadRemoved() as well as when the DownloadManager is going |
| 115 // down. |
| 116 virtual void OnDownloadDestructed(DownloadItem* download) {} |
113 | 117 |
114 protected: | 118 protected: |
115 virtual ~Observer() {} | 119 virtual ~Observer() {} |
116 }; | 120 }; |
117 | 121 |
118 // Interface for data that can be stored associated with (and owned | 122 // Interface for data that can be stored associated with (and owned |
119 // by) an object of this class via GetExternalData/SetExternalData. | 123 // by) an object of this class via GetExternalData/SetExternalData. |
120 class ExternalData { | 124 class ExternalData { |
121 public: | 125 public: |
122 virtual ~ExternalData() {}; | 126 virtual ~ExternalData() {}; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 virtual void SetExternalData(const void* key, ExternalData* data) = 0; | 374 virtual void SetExternalData(const void* key, ExternalData* data) = 0; |
371 | 375 |
372 virtual std::string DebugString(bool verbose) const = 0; | 376 virtual std::string DebugString(bool verbose) const = 0; |
373 | 377 |
374 virtual void MockDownloadOpenForTesting() = 0; | 378 virtual void MockDownloadOpenForTesting() = 0; |
375 }; | 379 }; |
376 | 380 |
377 } // namespace content | 381 } // namespace content |
378 | 382 |
379 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 383 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |