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/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
| 14 class GURL; |
| 15 |
| 16 namespace base { |
| 17 class FilePath; |
| 18 } |
| 19 |
14 namespace fileapi { | 20 namespace fileapi { |
15 class ExternalMountPoints; | 21 class ExternalMountPoints; |
16 } | 22 } |
17 | 23 |
18 namespace net { | 24 namespace net { |
19 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
20 } | 26 } |
21 | 27 |
22 namespace quota { | 28 namespace quota { |
23 class SpecialStoragePolicy; | 29 class SpecialStoragePolicy; |
24 } | 30 } |
25 | 31 |
26 class FilePath; | |
27 class GURL; | |
28 | |
29 namespace content { | 32 namespace content { |
30 | 33 |
31 class DownloadManager; | 34 class DownloadManager; |
32 class DownloadManagerDelegate; | 35 class DownloadManagerDelegate; |
33 class GeolocationPermissionContext; | 36 class GeolocationPermissionContext; |
34 class IndexedDBContext; | 37 class IndexedDBContext; |
35 class ResourceContext; | 38 class ResourceContext; |
36 class SiteInstance; | 39 class SiteInstance; |
37 class SpeechRecognitionPreferences; | 40 class SpeechRecognitionPreferences; |
38 class StoragePartition; | 41 class StoragePartition; |
(...skipping 23 matching lines...) Expand all Loading... |
62 const StoragePartitionCallback& callback); | 65 const StoragePartitionCallback& callback); |
63 static void AsyncObliterateStoragePartition( | 66 static void AsyncObliterateStoragePartition( |
64 BrowserContext* browser_context, | 67 BrowserContext* browser_context, |
65 const GURL& site, | 68 const GURL& site, |
66 const base::Closure& on_gc_required); | 69 const base::Closure& on_gc_required); |
67 | 70 |
68 // This function clears the contents of |active_paths| but does not take | 71 // This function clears the contents of |active_paths| but does not take |
69 // ownership of the pointer. | 72 // ownership of the pointer. |
70 static void GarbageCollectStoragePartitions( | 73 static void GarbageCollectStoragePartitions( |
71 BrowserContext* browser_context, | 74 BrowserContext* browser_context, |
72 scoped_ptr<base::hash_set<FilePath> > active_paths, | 75 scoped_ptr<base::hash_set<base::FilePath> > active_paths, |
73 const base::Closure& done); | 76 const base::Closure& done); |
74 | 77 |
75 // DON'T USE THIS. GetDefaultStoragePartition() is going away. | 78 // DON'T USE THIS. GetDefaultStoragePartition() is going away. |
76 // Use GetStoragePartition() instead. Ask ajwong@ if you have problems. | 79 // Use GetStoragePartition() instead. Ask ajwong@ if you have problems. |
77 static content::StoragePartition* GetDefaultStoragePartition( | 80 static content::StoragePartition* GetDefaultStoragePartition( |
78 BrowserContext* browser_context); | 81 BrowserContext* browser_context); |
79 | 82 |
80 // Ensures that the corresponding ResourceContext is initialized. Normally the | 83 // Ensures that the corresponding ResourceContext is initialized. Normally the |
81 // BrowserContext initializs the corresponding getters when its objects are | 84 // BrowserContext initializs the corresponding getters when its objects are |
82 // created, but if the embedder wants to pass the ResourceContext to another | 85 // created, but if the embedder wants to pass the ResourceContext to another |
83 // thread before they use BrowserContext, they should call this to make sure | 86 // thread before they use BrowserContext, they should call this to make sure |
84 // that the ResourceContext is ready. | 87 // that the ResourceContext is ready. |
85 static void EnsureResourceContextInitialized(BrowserContext* browser_context); | 88 static void EnsureResourceContextInitialized(BrowserContext* browser_context); |
86 | 89 |
87 // Tells the HTML5 objects on this context to persist their session state | 90 // Tells the HTML5 objects on this context to persist their session state |
88 // across the next restart. | 91 // across the next restart. |
89 static void SaveSessionState(BrowserContext* browser_context); | 92 static void SaveSessionState(BrowserContext* browser_context); |
90 | 93 |
91 // Tells the HTML5 objects on this context to purge any uneeded memory. | 94 // Tells the HTML5 objects on this context to purge any uneeded memory. |
92 static void PurgeMemory(BrowserContext* browser_context); | 95 static void PurgeMemory(BrowserContext* browser_context); |
93 | 96 |
94 virtual ~BrowserContext(); | 97 virtual ~BrowserContext(); |
95 | 98 |
96 // Returns the path of the directory where this context's data is stored. | 99 // Returns the path of the directory where this context's data is stored. |
97 virtual FilePath GetPath() = 0; | 100 virtual base::FilePath GetPath() = 0; |
98 | 101 |
99 // Return whether this context is incognito. Default is false. | 102 // Return whether this context is incognito. Default is false. |
100 // This doesn't belong here; http://crbug.com/89628 | 103 // This doesn't belong here; http://crbug.com/89628 |
101 virtual bool IsOffTheRecord() const = 0; | 104 virtual bool IsOffTheRecord() const = 0; |
102 | 105 |
103 // Returns the request context information associated with this context. Call | 106 // Returns the request context information associated with this context. Call |
104 // this only on the UI thread, since it can send notifications that should | 107 // this only on the UI thread, since it can send notifications that should |
105 // happen on the UI thread. | 108 // happen on the UI thread. |
106 // TODO(creis): Remove this version in favor of the one below. | 109 // TODO(creis): Remove this version in favor of the one below. |
107 virtual net::URLRequestContextGetter* GetRequestContext() = 0; | 110 virtual net::URLRequestContextGetter* GetRequestContext() = 0; |
108 | 111 |
109 // Returns the request context appropriate for the given renderer. If the | 112 // Returns the request context appropriate for the given renderer. If the |
110 // renderer process doesn't have an associated installed app, or if the | 113 // renderer process doesn't have an associated installed app, or if the |
111 // installed app's is_storage_isolated() returns false, this is equivalent to | 114 // installed app's is_storage_isolated() returns false, this is equivalent to |
112 // calling GetRequestContext(). | 115 // calling GetRequestContext(). |
113 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( | 116 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
114 int renderer_child_id) = 0; | 117 int renderer_child_id) = 0; |
115 | 118 |
116 virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( | 119 virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( |
117 const FilePath& partition_path, | 120 const base::FilePath& partition_path, |
118 bool in_memory) = 0; | 121 bool in_memory) = 0; |
119 | 122 |
120 // Returns the default request context for media resources associated with | 123 // Returns the default request context for media resources associated with |
121 // this context. | 124 // this context. |
122 // TODO(creis): Remove this version in favor of the one below. | 125 // TODO(creis): Remove this version in favor of the one below. |
123 virtual net::URLRequestContextGetter* GetMediaRequestContext() = 0; | 126 virtual net::URLRequestContextGetter* GetMediaRequestContext() = 0; |
124 | 127 |
125 // Returns the request context for media resources associated with this | 128 // Returns the request context for media resources associated with this |
126 // context and renderer process. | 129 // context and renderer process. |
127 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( | 130 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
128 int renderer_child_id) = 0; | 131 int renderer_child_id) = 0; |
129 virtual net::URLRequestContextGetter* | 132 virtual net::URLRequestContextGetter* |
130 GetMediaRequestContextForStoragePartition( | 133 GetMediaRequestContextForStoragePartition( |
131 const FilePath& partition_path, | 134 const base::FilePath& partition_path, |
132 bool in_memory) = 0; | 135 bool in_memory) = 0; |
133 | 136 |
134 // Returns the resource context. | 137 // Returns the resource context. |
135 virtual ResourceContext* GetResourceContext() = 0; | 138 virtual ResourceContext* GetResourceContext() = 0; |
136 | 139 |
137 // Returns the DownloadManagerDelegate for this context. This will be called | 140 // Returns the DownloadManagerDelegate for this context. This will be called |
138 // once per context. The embedder owns the delegate and is responsible for | 141 // once per context. The embedder owns the delegate and is responsible for |
139 // ensuring that it outlives DownloadManager. It's valid to return NULL. | 142 // ensuring that it outlives DownloadManager. It's valid to return NULL. |
140 virtual DownloadManagerDelegate* GetDownloadManagerDelegate() = 0; | 143 virtual DownloadManagerDelegate* GetDownloadManagerDelegate() = 0; |
141 | 144 |
(...skipping 19 matching lines...) Expand all Loading... |
161 struct hash<content::BrowserContext*> { | 164 struct hash<content::BrowserContext*> { |
162 std::size_t operator()(content::BrowserContext* const& p) const { | 165 std::size_t operator()(content::BrowserContext* const& p) const { |
163 return reinterpret_cast<std::size_t>(p); | 166 return reinterpret_cast<std::size_t>(p); |
164 } | 167 } |
165 }; | 168 }; |
166 | 169 |
167 } // namespace BASE_HASH_NAMESPACE | 170 } // namespace BASE_HASH_NAMESPACE |
168 #endif | 171 #endif |
169 | 172 |
170 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ | 173 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ |
OLD | NEW |