| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 5 #ifndef EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
| 6 #define EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 6 #define EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 #include "extensions/browser/extension_registry_factory.h" |
| 12 #include "extensions/browser/extension_system_provider.h" | 13 #include "extensions/browser/extension_system_provider.h" |
| 13 #include "extensions/browser/extensions_browser_client.h" | 14 #include "extensions/browser/extensions_browser_client.h" |
| 15 #include "extensions/browser/process_manager_factory.h" |
| 14 | 16 |
| 15 namespace extensions { | 17 namespace extensions { |
| 16 | 18 |
| 17 template <typename T> | 19 template <typename T> |
| 18 class BrowserContextKeyedAPIFactory; | 20 class BrowserContextKeyedAPIFactory; |
| 19 | 21 |
| 20 // Instantiations of BrowserContextKeyedAPIFactory should use this base class | 22 // Instantiations of BrowserContextKeyedAPIFactory should use this base class |
| 21 // and also define a static const char* service_name() function (used in the | 23 // and also define a static const char* service_name() function (used in the |
| 22 // BrowserContextKeyedBaseFactory constructor). These fields should | 24 // BrowserContextKeyedBaseFactory constructor). These fields should |
| 23 // be accessible to the BrowserContextKeyedAPIFactory for the service. | 25 // be accessible to the BrowserContextKeyedAPIFactory for the service. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // your header file after the BrowserContextKeyedAPI class definition. | 90 // your header file after the BrowserContextKeyedAPI class definition. |
| 89 // Then in the cc file (or inline in the header), define it, e.g.: | 91 // Then in the cc file (or inline in the header), define it, e.g.: |
| 90 // template <> | 92 // template <> |
| 91 // void BrowserContextKeyedAPIFactory< | 93 // void BrowserContextKeyedAPIFactory< |
| 92 // PushMessagingAPI>::DeclareFactoryDependencies() { | 94 // PushMessagingAPI>::DeclareFactoryDependencies() { |
| 93 // DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 95 // DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 94 // DependsOn(ProfileSyncServiceFactory::GetInstance()); | 96 // DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| 95 // } | 97 // } |
| 96 void DeclareFactoryDependencies() { | 98 void DeclareFactoryDependencies() { |
| 97 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 99 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 100 DependsOn(ExtensionRegistryFactory::GetInstance()); |
| 101 DependsOn(ProcessManagerFactory::GetInstance()); |
| 98 } | 102 } |
| 99 | 103 |
| 100 BrowserContextKeyedAPIFactory() | 104 BrowserContextKeyedAPIFactory() |
| 101 : BrowserContextKeyedServiceFactory( | 105 : BrowserContextKeyedServiceFactory( |
| 102 T::service_name(), | 106 T::service_name(), |
| 103 BrowserContextDependencyManager::GetInstance()) { | 107 BrowserContextDependencyManager::GetInstance()) { |
| 104 DeclareFactoryDependencies(); | 108 DeclareFactoryDependencies(); |
| 105 } | 109 } |
| 106 | 110 |
| 107 ~BrowserContextKeyedAPIFactory() override {} | 111 ~BrowserContextKeyedAPIFactory() override {} |
| (...skipping 25 matching lines...) Expand all Loading... |
| 133 bool ServiceIsNULLWhileTesting() const override { | 137 bool ServiceIsNULLWhileTesting() const override { |
| 134 return T::kServiceIsNULLWhileTesting; | 138 return T::kServiceIsNULLWhileTesting; |
| 135 } | 139 } |
| 136 | 140 |
| 137 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); | 141 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedAPIFactory); |
| 138 }; | 142 }; |
| 139 | 143 |
| 140 } // namespace extensions | 144 } // namespace extensions |
| 141 | 145 |
| 142 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ | 146 #endif // EXTENSIONS_BROWSER_BROWSER_CONTEXT_KEYED_API_FACTORY_H_ |
| OLD | NEW |