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

Unified Diff: extensions/browser/browser_context_keyed_api_factory.h

Issue 2863213004: ProcessManagerFactory: fix dependencies in ApiResourceManager, LazyBgndTaskFactory (Closed)
Patch Set: devlin feedback Created 3 years, 7 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 | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/process_manager_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/browser_context_keyed_api_factory.h
diff --git a/extensions/browser/browser_context_keyed_api_factory.h b/extensions/browser/browser_context_keyed_api_factory.h
index 1316c08875870e9263f000909b929389661d860b..ab67cc7659664138522af4bfd56eed9d164ef1f9 100644
--- a/extensions/browser/browser_context_keyed_api_factory.h
+++ b/extensions/browser/browser_context_keyed_api_factory.h
@@ -66,6 +66,31 @@ class BrowserContextKeyedAPI : public KeyedService {
// }
};
+// Declare dependencies on other factories.
+// By default, ExtensionSystemFactory is the only dependency; however,
+// specializations can override this. Declare your specialization in
+// your header file after the BrowserContextKeyedAPI class definition.
+// Declare this struct in the header file. The implementation may optionally
+// be placed in your .cc file.
Devlin 2017/05/15 18:24:52 For background, maybe we should include a comment
Kevin M 2017/05/15 18:34:39 Done - added the explanation to the deprecated Dec
Devlin 2017/05/15 18:37:47 I dunno - I think it might help avoid a well-meani
Kevin M 2017/05/15 18:43:01 Done.
+// template <>
+// struct BrowserContextFactoryDependencies<MyService> {
+// static void DeclareFactoryDependencies(
+// BrowserContextKeyedAPIFactory<ApiResourceManager<T>>* factory) {
+// factory->DependsOn(
+// ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+// factory->DependsOn(ProfileSyncServiceFactory::GetInstance());
+// ...
+// }
+// };
+template <typename T>
+struct BrowserContextFactoryDependencies {
+ static void DeclareFactoryDependencies(
+ BrowserContextKeyedAPIFactory<T>* factory) {
+ factory->DependsOn(
+ ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+ }
+};
+
// A template for factories for KeyedServices that manage extension APIs. T is
// a KeyedService that uses this factory template instead of its own separate
// factory definition to manage its per-profile instances.
@@ -82,19 +107,11 @@ class BrowserContextKeyedAPIFactory : public BrowserContextKeyedServiceFactory {
T::GetFactoryInstance()->GetServiceForBrowserContext(context, false));
}
- // Declare dependencies on other factories.
- // By default, ExtensionSystemFactory is the only dependency; however,
- // specializations can override this. Declare your specialization in
- // your header file after the BrowserContextKeyedAPI class definition.
- // Then in the cc file (or inline in the header), define it, e.g.:
- // template <>
- // void BrowserContextKeyedAPIFactory<
- // PushMessagingAPI>::DeclareFactoryDependencies() {
- // DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
- // DependsOn(ProfileSyncServiceFactory::GetInstance());
- // }
+ // Declares dependencies on other factories.
+ // Deprecated. Use BrowserContextFactoryDependencies<> to declare
+ // dependencies instead.
void DeclareFactoryDependencies() {
- DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+ BrowserContextFactoryDependencies<T>::DeclareFactoryDependencies(this);
}
BrowserContextKeyedAPIFactory()
@@ -107,6 +124,8 @@ class BrowserContextKeyedAPIFactory : public BrowserContextKeyedServiceFactory {
~BrowserContextKeyedAPIFactory() override {}
private:
+ friend struct BrowserContextFactoryDependencies<T>;
+
// BrowserContextKeyedServiceFactory implementation.
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override {
« no previous file with comments | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/process_manager_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698