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 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 | 33 |
34 class DownloadManager; | 34 class DownloadManager; |
35 class DownloadManagerDelegate; | 35 class DownloadManagerDelegate; |
36 class GeolocationPermissionContext; | 36 class GeolocationPermissionContext; |
37 class IndexedDBContext; | 37 class IndexedDBContext; |
38 class ResourceContext; | 38 class ResourceContext; |
39 class SiteInstance; | 39 class SiteInstance; |
40 class StoragePartition; | 40 class StoragePartition; |
| 41 struct CookieStoreConfig; |
41 | 42 |
42 // This class holds the context needed for a browsing session. | 43 // This class holds the context needed for a browsing session. |
43 // It lives on the UI thread. All these methods must only be called on the UI | 44 // It lives on the UI thread. All these methods must only be called on the UI |
44 // thread. | 45 // thread. |
45 class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { | 46 class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { |
46 public: | 47 public: |
47 static DownloadManager* GetDownloadManager(BrowserContext* browser_context); | 48 static DownloadManager* GetDownloadManager(BrowserContext* browser_context); |
48 | 49 |
49 // Returns BrowserContext specific external mount points. It may return NULL | 50 // Returns BrowserContext specific external mount points. It may return NULL |
50 // if the context doesn't have any BrowserContext specific external mount | 51 // if the context doesn't have any BrowserContext specific external mount |
(...skipping 13 matching lines...) Expand all Loading... |
64 const GURL& site, | 65 const GURL& site, |
65 const base::Closure& on_gc_required); | 66 const base::Closure& on_gc_required); |
66 | 67 |
67 // This function clears the contents of |active_paths| but does not take | 68 // This function clears the contents of |active_paths| but does not take |
68 // ownership of the pointer. | 69 // ownership of the pointer. |
69 static void GarbageCollectStoragePartitions( | 70 static void GarbageCollectStoragePartitions( |
70 BrowserContext* browser_context, | 71 BrowserContext* browser_context, |
71 scoped_ptr<base::hash_set<base::FilePath> > active_paths, | 72 scoped_ptr<base::hash_set<base::FilePath> > active_paths, |
72 const base::Closure& done); | 73 const base::Closure& done); |
73 | 74 |
74 // DON'T USE THIS. GetDefaultStoragePartition() is going away. | 75 // Prefer GetStoragePartition() or GetStoragePartitionForSite() above. Only |
75 // Use GetStoragePartition() instead. Ask ajwong@ if you have problems. | 76 // use this if it is 100% certain that the cookie store, cache, etc., that |
| 77 // is returned by this will be the correct one. |
76 static content::StoragePartition* GetDefaultStoragePartition( | 78 static content::StoragePartition* GetDefaultStoragePartition( |
77 BrowserContext* browser_context); | 79 BrowserContext* browser_context); |
78 | 80 |
79 // Ensures that the corresponding ResourceContext is initialized. Normally the | 81 // Ensures that the corresponding ResourceContext is initialized. Normally the |
80 // BrowserContext initializs the corresponding getters when its objects are | 82 // BrowserContext initializs the corresponding getters when its objects are |
81 // created, but if the embedder wants to pass the ResourceContext to another | 83 // created, but if the embedder wants to pass the ResourceContext to another |
82 // thread before they use BrowserContext, they should call this to make sure | 84 // thread before they use BrowserContext, they should call this to make sure |
83 // that the ResourceContext is ready. | 85 // that the ResourceContext is ready. |
84 static void EnsureResourceContextInitialized(BrowserContext* browser_context); | 86 static void EnsureResourceContextInitialized(BrowserContext* browser_context); |
85 | 87 |
86 // Tells the HTML5 objects on this context to persist their session state | 88 // Tells the HTML5 objects on this context to persist their session state |
87 // across the next restart. | 89 // across the next restart. |
88 static void SaveSessionState(BrowserContext* browser_context); | 90 static void SaveSessionState(BrowserContext* browser_context); |
89 | 91 |
90 // Tells the HTML5 objects on this context to purge any uneeded memory. | 92 // Tells the HTML5 objects on this context to purge any uneeded memory. |
91 static void PurgeMemory(BrowserContext* browser_context); | 93 static void PurgeMemory(BrowserContext* browser_context); |
92 | 94 |
93 virtual ~BrowserContext(); | 95 virtual ~BrowserContext(); |
94 | 96 |
95 // Returns the path of the directory where this context's data is stored. | 97 // Returns the path of the directory where this context's data is stored. |
96 virtual base::FilePath GetPath() const = 0; | 98 virtual base::FilePath GetPath() const = 0; |
97 | 99 |
98 // Return whether this context is incognito. Default is false. | 100 // Return whether this context is incognito. Default is false. |
99 virtual bool IsOffTheRecord() const = 0; | 101 virtual bool IsOffTheRecord() const = 0; |
100 | 102 |
| 103 // Retrieves configuration parameters for CookieStores created by this |
| 104 // BrowserContext. |
| 105 virtual CookieStoreConfig GetCookieStoreConfig() = 0; |
| 106 |
101 // Returns the request context information associated with this context. Call | 107 // Returns the request context information associated with this context. Call |
102 // this only on the UI thread, since it can send notifications that should | 108 // this only on the UI thread, since it can send notifications that should |
103 // happen on the UI thread. | 109 // happen on the UI thread. |
104 // TODO(creis): Remove this version in favor of the one below. | 110 // TODO(creis): Remove this version in favor of the one below. |
105 virtual net::URLRequestContextGetter* GetRequestContext() = 0; | 111 virtual net::URLRequestContextGetter* GetRequestContext() = 0; |
106 | 112 |
107 // Returns the request context appropriate for the given renderer. If the | 113 // Returns the request context appropriate for the given renderer. If the |
108 // renderer process doesn't have an associated installed app, or if the | 114 // renderer process doesn't have an associated installed app, or if the |
109 // installed app doesn't have isolated storage, this is equivalent to calling | 115 // installed app doesn't have isolated storage, this is equivalent to calling |
110 // GetRequestContext(). | 116 // GetRequestContext(). |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 struct hash<content::BrowserContext*> { | 166 struct hash<content::BrowserContext*> { |
161 std::size_t operator()(content::BrowserContext* const& p) const { | 167 std::size_t operator()(content::BrowserContext* const& p) const { |
162 return reinterpret_cast<std::size_t>(p); | 168 return reinterpret_cast<std::size_t>(p); |
163 } | 169 } |
164 }; | 170 }; |
165 | 171 |
166 } // namespace BASE_HASH_NAMESPACE | 172 } // namespace BASE_HASH_NAMESPACE |
167 #endif | 173 #endif |
168 | 174 |
169 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 175 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
OLD | NEW |