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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/graph/browser_context_configuration.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/browser_context.h
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h
index c7c664d097e5d5fe2a4c5546d84afadfceb22ebf..f38d38635051b57f00025813ab1300e1d5c75e23 100644
--- a/content/public/browser/browser_context.h
+++ b/content/public/browser/browser_context.h
@@ -5,11 +5,14 @@
#ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_
#define CONTENT_PUBLIC_BROWSER_BROWSER_CONTEXT_H_
-#include "base/callback_forward.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
#include "base/hash_tables.h"
#include "base/memory/scoped_ptr.h"
#include "base/supports_user_data.h"
#include "content/common/content_export.h"
+#include "content/public/browser/graph/browser_context_dependency_visitor.h"
+#include "content/public/browser/graph/browser_context_dependency_visitor_impl.h"
#include "ui/base/clipboard/clipboard_sourcetag.h"
class GURL;
@@ -22,6 +25,10 @@ namespace fileapi {
class ExternalMountPoints;
}
+namespace graph {
+class DependencyManagerInstance;
+}
+
namespace net {
class URLRequestContextGetter;
}
@@ -154,6 +161,64 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// Returns a special storage policy implementation, or NULL.
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() = 0;
+
+ // Retrieves a Component instance associated with the BrowserContext.
+ // |completion_callback| will be invoked when the Component instance is fully
+ // initialized, or during Profile shutdown (with a NULL Component pointer) if
+ // the initialization has not completed by that time.
+ // This should only be called on the UI thread. |completion_callback| will
+ // always be called back on the UI thread.
+ template <typename Component>
+ void Get(base::Callback<void(Component*)> completion_callback) {
+ VisitDependencyManager(scoped_ptr<BrowserContextDependencyVisitor>(
+ new BrowserContextDependencyVisitorImpl<Component>(
+ completion_callback)));
+ }
+
+ // Attempts to synchronously retrieve a Component instance associated with the
+ // BrowserContext. If the component is available, the return value will be
+ // |true|, and |component_storage| will contain the component instance. If the
+ // component is not available, then the return value will be |false| and
+ // |component_storage| will contain a NULL pointer.
+ // It is the callers responsibility to check that the component was
+ // successfully retrieved before using it.
+ template <typename Component>
+ bool GetNow(Component** component_storage) WARN_UNUSED_RESULT {
+ graph::DependencyManagerInstance* manager = GetDependencyManager();
+ if (!manager) {
+ *component_storage = NULL;
+ return false;
+ }
+
+ return manager->GetNow<Component>(component_storage);
+ }
+
+ // Attempts to synchronously retrieve a Component instance associated with the
+ // BrowserContext. If the component is available, the return value will be
+ // |true|, and |component_storage| will contain the component instance. If the
+ // component is not available, then the return value will be |false| and
+ // |component_storage| will contain a NULL pointer.
+ // It is the callers responsibility to check that the component was
+ // successfully retrieved before using it.
+ template <typename Component> bool IsDefined() {
+ graph::DependencyManagerInstance* manager = GetDependencyManager();
+ if (!manager) {
+ return false;
+ }
+
+ return manager->IsDefined<Component>();
+ }
+
+ private:
+ // Executes visitor against the DependencyManagerInstance associated with
+ // this BrowserContext, possibly asynchronously if the
+ // DependencyManagerInstance is not fully initialized yet.
+ // May be executed against a NULL DependencyManagerInstance pointer if
+ // shutdown begins before the DependencyManagerInstance is fully initialized.
+ virtual void VisitDependencyManager(
+ scoped_ptr<content::BrowserContextDependencyVisitor> visitor) = 0;
+
+ virtual graph::DependencyManagerInstance* GetDependencyManager() = 0;
};
} // namespace content
« 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