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 25 matching lines...) Expand all Loading... |
36 class Time; | 36 class Time; |
37 class TimeDelta; | 37 class TimeDelta; |
38 } | 38 } |
39 | 39 |
40 namespace content { | 40 namespace content { |
41 | 41 |
42 class BrowserContext; | 42 class BrowserContext; |
43 class DownloadId; | 43 class DownloadId; |
44 class DownloadManager; | 44 class DownloadManager; |
45 class WebContents; | 45 class WebContents; |
46 struct DownloadPersistentStoreInfo; | |
47 | 46 |
48 // One DownloadItem per download. This is the model class that stores all the | 47 // One DownloadItem per download. This is the model class that stores all the |
49 // state for a download. Multiple views, such as a tab's download shelf and the | 48 // state for a download. Multiple views, such as a tab's download shelf and the |
50 // Destination tab's download view, may refer to a given DownloadItem. | 49 // Destination tab's download view, may refer to a given DownloadItem. |
51 // | 50 // |
52 // This is intended to be used only on the UI thread. | 51 // This is intended to be used only on the UI thread. |
53 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { | 52 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { |
54 public: | 53 public: |
55 enum DownloadState { | 54 enum DownloadState { |
56 // Download is actively progressing. | 55 // Download is actively progressing. |
(...skipping 25 matching lines...) Expand all Loading... |
82 }; | 81 }; |
83 | 82 |
84 // How the final target path should be used. | 83 // How the final target path should be used. |
85 enum TargetDisposition { | 84 enum TargetDisposition { |
86 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. | 85 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. |
87 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual | 86 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual |
88 // target. Implies | 87 // target. Implies |
89 // TARGET_DISPOSITION_OVERWRITE. | 88 // TARGET_DISPOSITION_OVERWRITE. |
90 }; | 89 }; |
91 | 90 |
92 // A fake download table ID which represents a download that has started, | |
93 // but is not yet in the table. | |
94 static const int kUninitializedHandle; | |
95 | |
96 static const char kEmptyFileHash[]; | 91 static const char kEmptyFileHash[]; |
97 | 92 |
98 // Interface that observers of a particular download must implement in order | 93 // Interface that observers of a particular download must implement in order |
99 // to receive updates to the download's status. | 94 // to receive updates to the download's status. |
100 class CONTENT_EXPORT Observer { | 95 class CONTENT_EXPORT Observer { |
101 public: | 96 public: |
102 virtual void OnDownloadUpdated(DownloadItem* download) {} | 97 virtual void OnDownloadUpdated(DownloadItem* download) {} |
103 virtual void OnDownloadOpened(DownloadItem* download) {} | 98 virtual void OnDownloadOpened(DownloadItem* download) {} |
104 virtual void OnDownloadRemoved(DownloadItem* download) {} | 99 virtual void OnDownloadRemoved(DownloadItem* download) {} |
105 | 100 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // still in progress, marks the download to be opened when it is complete. | 145 // still in progress, marks the download to be opened when it is complete. |
151 virtual void OpenDownload() = 0; | 146 virtual void OpenDownload() = 0; |
152 | 147 |
153 // Show the download via the OS shell. | 148 // Show the download via the OS shell. |
154 virtual void ShowDownloadInShell() = 0; | 149 virtual void ShowDownloadInShell() = 0; |
155 | 150 |
156 // State accessors ----------------------------------------------------------- | 151 // State accessors ----------------------------------------------------------- |
157 | 152 |
158 virtual int32 GetId() const = 0; | 153 virtual int32 GetId() const = 0; |
159 virtual DownloadId GetGlobalId() const = 0; | 154 virtual DownloadId GetGlobalId() const = 0; |
160 virtual int64 GetDbHandle() const = 0; | |
161 virtual DownloadState GetState() const = 0; | 155 virtual DownloadState GetState() const = 0; |
162 | 156 |
163 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. | 157 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. |
164 virtual DownloadInterruptReason GetLastReason() const = 0; | 158 virtual DownloadInterruptReason GetLastReason() const = 0; |
165 | 159 |
166 virtual bool IsPaused() const = 0; | 160 virtual bool IsPaused() const = 0; |
167 virtual bool IsTemporary() const = 0; | 161 virtual bool IsTemporary() const = 0; |
168 virtual bool IsPersisted() const = 0; | |
169 | 162 |
170 // Convenience routines for accessing GetState() results conceptually ----- | 163 // Convenience routines for accessing GetState() results conceptually ----- |
171 | 164 |
172 // Returns true if the download needs more data. | 165 // Returns true if the download needs more data. |
173 virtual bool IsPartialDownload() const = 0; | 166 virtual bool IsPartialDownload() const = 0; |
174 | 167 |
175 // Returns true if the download is still receiving data. | 168 // Returns true if the download is still receiving data. |
176 virtual bool IsInProgress() const = 0; | 169 virtual bool IsInProgress() const = 0; |
177 | 170 |
178 // Returns true if the download has been cancelled or was interrupted. | 171 // Returns true if the download has been cancelled or was interrupted. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 virtual bool GetOpenWhenComplete() const = 0; | 285 virtual bool GetOpenWhenComplete() const = 0; |
293 | 286 |
294 // Returns true if the download has been auto-opened by the system. | 287 // Returns true if the download has been auto-opened by the system. |
295 virtual bool GetAutoOpened() = 0; | 288 virtual bool GetAutoOpened() = 0; |
296 | 289 |
297 // Returns true if the download has been opened. | 290 // Returns true if the download has been opened. |
298 virtual bool GetOpened() const = 0; | 291 virtual bool GetOpened() const = 0; |
299 | 292 |
300 // Misc State accessors --------------------------------------------------- | 293 // Misc State accessors --------------------------------------------------- |
301 | 294 |
302 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; | |
303 virtual BrowserContext* GetBrowserContext() const = 0; | 295 virtual BrowserContext* GetBrowserContext() const = 0; |
304 virtual WebContents* GetWebContents() const = 0; | 296 virtual WebContents* GetWebContents() const = 0; |
305 | 297 |
306 // External state transitions/setters ---------------------------------------- | 298 // External state transitions/setters ---------------------------------------- |
307 // TODO(rdsmith): These should all be removed; the download item should | 299 // TODO(rdsmith): These should all be removed; the download item should |
308 // control its own state transitions. | 300 // control its own state transitions. |
309 | 301 |
310 // Called by the delegate if it delayed opening the download after | 302 // Called by the delegate if it delayed opening the download after |
311 // the download has actually been opened. | 303 // the download has actually been opened. |
312 virtual void DelayedDownloadOpened(bool auto_opened) = 0; | 304 virtual void DelayedDownloadOpened(bool auto_opened) = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
332 virtual void SetDisplayName(const FilePath& name) = 0; | 324 virtual void SetDisplayName(const FilePath& name) = 0; |
333 | 325 |
334 // Debug/testing ------------------------------------------------------------- | 326 // Debug/testing ------------------------------------------------------------- |
335 virtual std::string DebugString(bool verbose) const = 0; | 327 virtual std::string DebugString(bool verbose) const = 0; |
336 virtual void MockDownloadOpenForTesting() = 0; | 328 virtual void MockDownloadOpenForTesting() = 0; |
337 }; | 329 }; |
338 | 330 |
339 } // namespace content | 331 } // namespace content |
340 | 332 |
341 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 333 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |