Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Unified Diff: content/public/browser/browser_context.h

Issue 9348109: Add extra data to BrowserContext so that content layer and other embedders can stash data with it t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/ssl/ssl_host_state_unittest.cc ('k') | content/public/browser/browser_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/ssl/ssl_host_state_unittest.cc ('k') | content/public/browser/browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698