| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 virtual bool GetAutoOpened() = 0; | 289 virtual bool GetAutoOpened() = 0; |
| 297 | 290 |
| 298 // Returns true if the download has been opened. | 291 // Returns true if the download has been opened. |
| 299 virtual bool GetOpened() const = 0; | 292 virtual bool GetOpened() const = 0; |
| 300 | 293 |
| 301 // Misc State accessors --------------------------------------------------- | 294 // Misc State accessors --------------------------------------------------- |
| 302 | 295 |
| 303 // Returns true if this item matches |query|. |query| must be lower-cased. | 296 // Returns true if this item matches |query|. |query| must be lower-cased. |
| 304 virtual bool MatchesQuery(const string16& query) const = 0; | 297 virtual bool MatchesQuery(const string16& query) const = 0; |
| 305 | 298 |
| 306 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; | |
| 307 virtual BrowserContext* GetBrowserContext() const = 0; | 299 virtual BrowserContext* GetBrowserContext() const = 0; |
| 308 virtual WebContents* GetWebContents() const = 0; | 300 virtual WebContents* GetWebContents() const = 0; |
| 309 | 301 |
| 310 // External state transitions/setters ---------------------------------------- | 302 // External state transitions/setters ---------------------------------------- |
| 311 // TODO(rdsmith): These should all be removed; the download item should | 303 // TODO(rdsmith): These should all be removed; the download item should |
| 312 // control its own state transitions. | 304 // control its own state transitions. |
| 313 | 305 |
| 314 // Called by the delegate if it delayed opening the download after | 306 // Called by the delegate if it delayed opening the download after |
| 315 // the download has actually been opened. | 307 // the download has actually been opened. |
| 316 virtual void DelayedDownloadOpened(bool auto_opened) = 0; | 308 virtual void DelayedDownloadOpened(bool auto_opened) = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 336 virtual void SetDisplayName(const FilePath& name) = 0; | 328 virtual void SetDisplayName(const FilePath& name) = 0; |
| 337 | 329 |
| 338 // Debug/testing ------------------------------------------------------------- | 330 // Debug/testing ------------------------------------------------------------- |
| 339 virtual std::string DebugString(bool verbose) const = 0; | 331 virtual std::string DebugString(bool verbose) const = 0; |
| 340 virtual void MockDownloadOpenForTesting() = 0; | 332 virtual void MockDownloadOpenForTesting() = 0; |
| 341 }; | 333 }; |
| 342 | 334 |
| 343 } // namespace content | 335 } // namespace content |
| 344 | 336 |
| 345 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 337 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| OLD | NEW |