Index: content/public/browser/download_item.h |
diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h |
index 20dc06b715698c8fbd5dd31d42c2fa39996bc22d..aecf44021af3e897d2dea0eb7b8004340b6ffa5c 100644 |
--- a/content/public/browser/download_item.h |
+++ b/content/public/browser/download_item.h |
@@ -23,6 +23,7 @@ |
#include "base/file_path.h" |
#include "base/string16.h" |
+#include "base/supports_user_data.h" |
#include "content/public/browser/download_danger_type.h" |
#include "content/public/browser/download_interrupt_reasons.h" |
#include "content/public/common/page_transition_types.h" |
@@ -49,7 +50,7 @@ struct DownloadPersistentStoreInfo; |
// Destination tab's download view, may refer to a given DownloadItem. |
// |
// This is intended to be used only on the UI thread. |
-class CONTENT_EXPORT DownloadItem { |
+class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { |
public: |
enum DownloadState { |
// Download is actively progressing. |
@@ -61,10 +62,6 @@ class CONTENT_EXPORT DownloadItem { |
// Download has been cancelled. |
CANCELLED, |
- // This state indicates that the download item is about to be destroyed, |
- // and observers seeing this state should release all references. |
- REMOVING, |
- |
// This state indicates that the download has been interrupted. |
INTERRUPTED, |
@@ -102,22 +99,23 @@ class CONTENT_EXPORT DownloadItem { |
// to receive updates to the download's status. |
class CONTENT_EXPORT Observer { |
public: |
- virtual void OnDownloadUpdated(DownloadItem* download) = 0; |
+ virtual void OnDownloadUpdated(DownloadItem* download) {} |
// Called when a downloaded file has been opened. |
- virtual void OnDownloadOpened(DownloadItem* download) = 0; |
+ virtual void OnDownloadOpened(DownloadItem* download) {} |
+ |
+ // Called when the user removes a download. |
+ virtual void OnDownloadRemoved(DownloadItem* download) {} |
+ |
+ // Called when the download is being destroyed. This happens after |
+ // every OnDownloadRemoved() as well as when the DownloadManager is going |
+ // down. |
+ virtual void OnDownloadDestroyed(DownloadItem* download) {} |
protected: |
virtual ~Observer() {} |
}; |
- // Interface for data that can be stored associated with (and owned |
- // by) an object of this class via GetExternalData/SetExternalData. |
- class ExternalData { |
- public: |
- virtual ~ExternalData() {}; |
- }; |
- |
virtual ~DownloadItem() {} |
virtual void AddObserver(DownloadItem::Observer* observer) = 0; |
@@ -225,8 +223,6 @@ class CONTENT_EXPORT DownloadItem { |
// true. |
virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; |
- virtual bool IsPersisted() const = 0; |
- |
// Accessors |
virtual const std::string& GetHash() const = 0; |
virtual DownloadState GetState() const = 0; |
@@ -247,7 +243,6 @@ class CONTENT_EXPORT DownloadItem { |
virtual DownloadId GetGlobalId() const = 0; |
virtual base::Time GetStartTime() const = 0; |
virtual base::Time GetEndTime() const = 0; |
- virtual int64 GetDbHandle() const = 0; |
virtual bool IsPaused() const = 0; |
virtual bool GetOpenWhenComplete() const = 0; |
virtual void SetOpenWhenComplete(bool open) = 0; |
@@ -272,7 +267,6 @@ class CONTENT_EXPORT DownloadItem { |
virtual const std::string& GetETag() const = 0; |
virtual DownloadInterruptReason GetLastReason() const = 0; |
- virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; |
virtual BrowserContext* GetBrowserContext() const = 0; |
virtual WebContents* GetWebContents() const = 0; |
@@ -291,22 +285,6 @@ class CONTENT_EXPORT DownloadItem { |
// but does not for dangerous downloads until the name is verified. |
virtual FilePath GetUserVerifiedFilePath() const = 0; |
- // Manage data owned by other subsystems associated with the |
- // DownloadItem. By custom, key is the address of a |
- // static char subsystem_specific_string[] = ".."; defined |
- // in the subsystem, but the only requirement of this interface |
- // is that the key be unique over all data stored with this |
- // DownloadItem. |
- // |
- // Note that SetExternalData takes ownership of the |
- // passed object; it will be destroyed when the DownloadItem is. |
- // If an object is already held by the DownloadItem associated with |
- // the passed key, it will be destroyed if overwriten by a new pointer |
- // (overwrites by the same pointer are ignored). |
- virtual ExternalData* GetExternalData(const void* key) = 0; |
- virtual const ExternalData* GetExternalData(const void* key) const = 0; |
- virtual void SetExternalData(const void* key, ExternalData* data) = 0; |
- |
virtual std::string DebugString(bool verbose) const = 0; |
virtual void MockDownloadOpenForTesting() = 0; |