Chromium Code Reviews| Index: content/public/browser/browser_context.h |
| =================================================================== |
| --- content/public/browser/browser_context.h (revision 121897) |
| +++ content/public/browser/browser_context.h (working copy) |
| @@ -6,7 +6,10 @@ |
| #define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| #pragma once |
| +#include <map> |
| + |
| #include "base/hash_tables.h" |
| +#include "base/memory/linked_ptr.h" |
| #include "content/common/content_export.h" |
| namespace fileapi { |
| @@ -42,6 +45,19 @@ |
| // It lives on the UI thread. |
| class CONTENT_EXPORT BrowserContext { |
| public: |
| + // Derive from this class and add your own data members to associate extra |
| + // information with a BrowserContext. Use GetUserData(key) and SetUserData() |
| + class UserData { |
|
darin (slow to review)
2012/02/15 00:54:42
Are you sure you want a map? It seems like you co
jam
2012/02/15 01:01:17
I was thinking that each object that hangs off Bro
|
| + public: |
| + virtual ~UserData() {} |
| + }; |
| + |
| + // The user data allows content and the embedder to associate data with this |
| + // BrowserContet. Multiple user data values can be stored under different |
| + // keys. This object will TAKE OWNERSHIP of the given data pointer. |
| + UserData* GetUserData(const void* key) const; |
| + void SetUserData(const void* key, UserData* data); |
| + |
| virtual ~BrowserContext(); |
| // Returns the path of the directory where this context's data is stored. |
| @@ -97,6 +113,10 @@ |
| virtual ChromeBlobStorageContext* GetBlobStorageContext() = 0; |
| virtual ChromeAppCacheService* GetAppCacheService() = 0; |
| virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; |
| + |
| + private: |
| + typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; |
| + UserDataMap user_data_; |
| }; |
| } // namespace content |