Index: content/browser/download/download_item.h |
diff --git a/content/browser/download/download_item.h b/content/browser/download/download_item.h |
index 3d3b0e7ace3a8b7454f1f7cc31088b3a2c5cc6e7..bc1f9657ad636b8aaa220b9c4da8f4d13fade13a 100644 |
--- a/content/browser/download/download_item.h |
+++ b/content/browser/download/download_item.h |
@@ -18,6 +18,7 @@ |
#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
#pragma once |
+#include <map> |
#include <string> |
#include "base/basictypes.h" |
@@ -117,6 +118,13 @@ class CONTENT_EXPORT DownloadItem { |
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() {}; |
+ }; |
+ |
// Constructing from persistent store: |
DownloadItem(DownloadManager* download_manager, |
const DownloadPersistentStoreInfo& info); |
@@ -349,6 +357,20 @@ class CONTENT_EXPORT DownloadItem { |
void MockDownloadOpenForTesting() { open_enabled_ = false; } |
+ // 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 on overwrite. |
+ ExternalData* GetExternalData(void* key); |
+ void SetExternalData(void* key, ExternalData* data); |
+ |
private: |
// Construction common to all constructors. |active| should be true for new |
// downloads and false for downloads from the history. |
@@ -492,6 +514,10 @@ class CONTENT_EXPORT DownloadItem { |
// Did the delegate delay calling Complete on this download? |
bool delegate_delayed_complete_; |
+ // External Data storage. All objects in the store |
+ // are owned by the DownloadItem. |
+ std::map<void*, ExternalData*> external_data_map_; |
asanka
2011/11/16 03:52:19
Would a std::map<const void*, ExternalData*> be be
Randy Smith (Not in Mondays)
2011/11/18 02:02:57
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
}; |