Chromium Code Reviews| 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 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | |
| 10 | |
| 9 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "base/memory/linked_ptr.h" | |
| 10 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 11 | 14 |
| 12 namespace fileapi { | 15 namespace fileapi { |
| 13 class FileSystemContext; | 16 class FileSystemContext; |
| 14 } | 17 } |
| 15 | 18 |
| 16 namespace net { | 19 namespace net { |
| 17 class URLRequestContextGetter; | 20 class URLRequestContextGetter; |
| 18 } | 21 } |
| 19 | 22 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 35 class DownloadManager; | 38 class DownloadManager; |
| 36 class GeolocationPermissionContext; | 39 class GeolocationPermissionContext; |
| 37 class HostZoomMap; | 40 class HostZoomMap; |
| 38 class ResourceContext; | 41 class ResourceContext; |
| 39 class SpeechInputPreferences; | 42 class SpeechInputPreferences; |
| 40 | 43 |
| 41 // This class holds the context needed for a browsing session. | 44 // This class holds the context needed for a browsing session. |
| 42 // It lives on the UI thread. | 45 // It lives on the UI thread. |
| 43 class CONTENT_EXPORT BrowserContext { | 46 class CONTENT_EXPORT BrowserContext { |
| 44 public: | 47 public: |
| 48 // Derive from this class and add your own data members to associate extra | |
| 49 // information with a BrowserContext. Use GetUserData(key) and SetUserData() | |
| 50 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
| |
| 51 public: | |
| 52 virtual ~UserData() {} | |
| 53 }; | |
| 54 | |
| 55 // The user data allows content and the embedder to associate data with this | |
| 56 // BrowserContet. Multiple user data values can be stored under different | |
| 57 // keys. This object will TAKE OWNERSHIP of the given data pointer. | |
| 58 UserData* GetUserData(const void* key) const; | |
| 59 void SetUserData(const void* key, UserData* data); | |
| 60 | |
| 45 virtual ~BrowserContext(); | 61 virtual ~BrowserContext(); |
| 46 | 62 |
| 47 // Returns the path of the directory where this context's data is stored. | 63 // Returns the path of the directory where this context's data is stored. |
| 48 virtual FilePath GetPath() = 0; | 64 virtual FilePath GetPath() = 0; |
| 49 | 65 |
| 50 // Return whether this context is incognito. Default is false. | 66 // Return whether this context is incognito. Default is false. |
| 51 // This doesn't belong here; http://crbug.com/89628 | 67 // This doesn't belong here; http://crbug.com/89628 |
| 52 virtual bool IsOffTheRecord() = 0; | 68 virtual bool IsOffTheRecord() = 0; |
| 53 | 69 |
| 54 // Returns the DownloadManager associated with this context. | 70 // Returns the DownloadManager associated with this context. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 virtual bool DidLastSessionExitCleanly() = 0; | 106 virtual bool DidLastSessionExitCleanly() = 0; |
| 91 | 107 |
| 92 // The following getters return references to various storage related | 108 // The following getters return references to various storage related |
| 93 // contexts associated with this browser context. | 109 // contexts associated with this browser context. |
| 94 virtual quota::QuotaManager* GetQuotaManager() = 0; | 110 virtual quota::QuotaManager* GetQuotaManager() = 0; |
| 95 virtual WebKitContext* GetWebKitContext() = 0; | 111 virtual WebKitContext* GetWebKitContext() = 0; |
| 96 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0; | 112 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0; |
| 97 virtual ChromeBlobStorageContext* GetBlobStorageContext() = 0; | 113 virtual ChromeBlobStorageContext* GetBlobStorageContext() = 0; |
| 98 virtual ChromeAppCacheService* GetAppCacheService() = 0; | 114 virtual ChromeAppCacheService* GetAppCacheService() = 0; |
| 99 virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; | 115 virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; |
| 116 | |
| 117 private: | |
| 118 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; | |
| 119 UserDataMap user_data_; | |
| 100 }; | 120 }; |
| 101 | 121 |
| 102 } // namespace content | 122 } // namespace content |
| 103 | 123 |
| 104 #if defined(COMPILER_GCC) | 124 #if defined(COMPILER_GCC) |
| 105 namespace BASE_HASH_NAMESPACE { | 125 namespace BASE_HASH_NAMESPACE { |
| 106 | 126 |
| 107 template<> | 127 template<> |
| 108 struct hash<content::BrowserContext*> { | 128 struct hash<content::BrowserContext*> { |
| 109 std::size_t operator()(content::BrowserContext* const& p) const { | 129 std::size_t operator()(content::BrowserContext* const& p) const { |
| 110 return reinterpret_cast<std::size_t>(p); | 130 return reinterpret_cast<std::size_t>(p); |
| 111 } | 131 } |
| 112 }; | 132 }; |
| 113 | 133 |
| 114 } // namespace BASE_HASH_NAMESPACE | 134 } // namespace BASE_HASH_NAMESPACE |
| 115 #endif | 135 #endif |
| 116 | 136 |
| 117 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 137 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
| OLD | NEW |