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

Side by Side Diff: content/public/browser/browser_context.h

Issue 18796007: Content API changes to integrate base/graph. (Closed) Base URL: marinoni.mon:/usr/local/google/src/chromium/src@base_graph_review
Patch Set: Created 7 years, 5 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 unified diff | Download patch
OLDNEW
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.h"
9 #include "base/compiler_specific.h"
9 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h" 12 #include "base/supports_user_data.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/graph/browser_context_dependency_visitor.h"
15 #include "content/public/browser/graph/browser_context_dependency_visitor_impl.h "
13 #include "ui/base/clipboard/clipboard_sourcetag.h" 16 #include "ui/base/clipboard/clipboard_sourcetag.h"
14 17
15 class GURL; 18 class GURL;
16 19
17 namespace base { 20 namespace base {
18 class FilePath; 21 class FilePath;
19 } 22 }
20 23
21 namespace fileapi { 24 namespace fileapi {
22 class ExternalMountPoints; 25 class ExternalMountPoints;
23 } 26 }
24 27
28 namespace graph {
29 class DependencyManagerInstance;
30 }
31
25 namespace net { 32 namespace net {
26 class URLRequestContextGetter; 33 class URLRequestContextGetter;
27 } 34 }
28 35
29 namespace quota { 36 namespace quota {
30 class SpecialStoragePolicy; 37 class SpecialStoragePolicy;
31 } 38 }
32 39
33 namespace content { 40 namespace content {
34 41
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // return NULL, in which case geolocation requests will always be allowed. 154 // return NULL, in which case geolocation requests will always be allowed.
148 virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0; 155 virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0;
149 156
150 // Returns the speech input preferences. SpeechRecognitionPreferences is a 157 // Returns the speech input preferences. SpeechRecognitionPreferences is a
151 // ref counted class, so callers should take a reference if needed. It's valid 158 // ref counted class, so callers should take a reference if needed. It's valid
152 // to return NULL. 159 // to return NULL.
153 virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() = 0; 160 virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() = 0;
154 161
155 // Returns a special storage policy implementation, or NULL. 162 // Returns a special storage policy implementation, or NULL.
156 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0; 163 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0;
164
165 // Retrieves a Component instance associated with the BrowserContext.
166 // |completion_callback| will be invoked when the Component instance is fully
167 // initialized, or during Profile shutdown (with a NULL Component pointer) if
168 // the initialization has not completed by that time.
169 // This should only be called on the UI thread. |completion_callback| will
170 // always be called back on the UI thread.
171 template <typename Component>
172 void Get(base::Callback<void(Component*)> completion_callback) {
173 VisitDependencyManager(scoped_ptr<BrowserContextDependencyVisitor>(
174 new BrowserContextDependencyVisitorImpl<Component>(
175 completion_callback)));
176 }
177
178 // Attempts to synchronously retrieve a Component instance associated with the
179 // BrowserContext. If the component is available, the return value will be
180 // |true|, and |component_storage| will contain the component instance. If the
181 // component is not available, then the return value will be |false| and
182 // |component_storage| will contain a NULL pointer.
183 // It is the callers responsibility to check that the component was
184 // successfully retrieved before using it.
185 template <typename Component>
186 bool GetNow(Component** component_storage) WARN_UNUSED_RESULT {
187 graph::DependencyManagerInstance* manager = GetDependencyManager();
188 if (!manager) {
189 *component_storage = NULL;
190 return false;
191 }
192
193 return manager->GetNow<Component>(component_storage);
194 }
195
196 // Attempts to synchronously retrieve a Component instance associated with the
197 // BrowserContext. If the component is available, the return value will be
198 // |true|, and |component_storage| will contain the component instance. If the
199 // component is not available, then the return value will be |false| and
200 // |component_storage| will contain a NULL pointer.
201 // It is the callers responsibility to check that the component was
202 // successfully retrieved before using it.
203 template <typename Component> bool IsDefined() {
204 graph::DependencyManagerInstance* manager = GetDependencyManager();
205 if (!manager) {
206 return false;
207 }
208
209 return manager->IsDefined<Component>();
210 }
211
212 private:
213 // Executes visitor against the DependencyManagerInstance associated with
214 // this BrowserContext, possibly asynchronously if the
215 // DependencyManagerInstance is not fully initialized yet.
216 // May be executed against a NULL DependencyManagerInstance pointer if
217 // shutdown begins before the DependencyManagerInstance is fully initialized.
218 virtual void VisitDependencyManager(
219 scoped_ptr<content::BrowserContextDependencyVisitor> visitor) = 0;
220
221 virtual graph::DependencyManagerInstance* GetDependencyManager() = 0;
157 }; 222 };
158 223
159 } // namespace content 224 } // namespace content
160 225
161 #if defined(COMPILER_GCC) 226 #if defined(COMPILER_GCC)
162 namespace BASE_HASH_NAMESPACE { 227 namespace BASE_HASH_NAMESPACE {
163 228
164 template<> 229 template<>
165 struct hash<content::BrowserContext*> { 230 struct hash<content::BrowserContext*> {
166 std::size_t operator()(content::BrowserContext* const& p) const { 231 std::size_t operator()(content::BrowserContext* const& p) const {
167 return reinterpret_cast<std::size_t>(p); 232 return reinterpret_cast<std::size_t>(p);
168 } 233 }
169 }; 234 };
170 235
171 } // namespace BASE_HASH_NAMESPACE 236 } // namespace BASE_HASH_NAMESPACE
172 #endif 237 #endif
173 238
174 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_ 239 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/graph/browser_context_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698