| 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 COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ | 5 #ifndef COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ |
| 6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ | 6 #define COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H
_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "components/keyed_service/core/keyed_service_export.h" | 10 #include "components/keyed_service/core/keyed_service_export.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // attached to a single |context|. Only test code is allowed to call this | 33 // attached to a single |context|. Only test code is allowed to call this |
| 34 // method. | 34 // method. |
| 35 // TODO(gab): This method can be removed entirely when | 35 // TODO(gab): This method can be removed entirely when |
| 36 // PrefService::DeprecatedGetPrefRegistry() is phased out. | 36 // PrefService::DeprecatedGetPrefRegistry() is phased out. |
| 37 void RegisterUserPrefsOnBrowserContextForTest( | 37 void RegisterUserPrefsOnBrowserContextForTest( |
| 38 content::BrowserContext* context); | 38 content::BrowserContext* context); |
| 39 | 39 |
| 40 // A function that supplies the instance of a KeyedService for a given | 40 // A function that supplies the instance of a KeyedService for a given |
| 41 // BrowserContext. This is used primarily for testing, where we want to feed | 41 // BrowserContext. This is used primarily for testing, where we want to feed |
| 42 // a specific mock into the BCKSF system. | 42 // a specific mock into the BCKSF system. |
| 43 typedef KeyedService* (*TestingFactoryFunction)( | 43 typedef scoped_ptr<KeyedService>(*TestingFactoryFunction)( |
| 44 content::BrowserContext* context); | 44 content::BrowserContext* context); |
| 45 | 45 |
| 46 // Associates |factory| with |context| so that |factory| is used to create | 46 // Associates |factory| with |context| so that |factory| is used to create |
| 47 // the KeyedService when requested. |factory| can be NULL to signal that | 47 // the KeyedService when requested. |factory| can be NULL to signal that |
| 48 // KeyedService should be NULL. Multiple calls to SetTestingFactory() are | 48 // KeyedService should be NULL. Multiple calls to SetTestingFactory() are |
| 49 // allowed; previous services will be shut down. | 49 // allowed; previous services will be shut down. |
| 50 void SetTestingFactory(content::BrowserContext* context, | 50 void SetTestingFactory(content::BrowserContext* context, |
| 51 TestingFactoryFunction factory); | 51 TestingFactoryFunction factory); |
| 52 | 52 |
| 53 // Associates |factory| with |context| and immediately returns the created | 53 // Associates |factory| with |context| and immediately returns the created |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 private: | 123 private: |
| 124 friend class BrowserContextDependencyManagerUnittests; | 124 friend class BrowserContextDependencyManagerUnittests; |
| 125 | 125 |
| 126 // Registers any user preferences on this service. This is called by | 126 // Registers any user preferences on this service. This is called by |
| 127 // RegisterPrefsIfNecessaryForContext() and should be overriden by any service | 127 // RegisterPrefsIfNecessaryForContext() and should be overriden by any service |
| 128 // that wants to register profile-specific preferences. | 128 // that wants to register profile-specific preferences. |
| 129 virtual void RegisterProfilePrefs( | 129 virtual void RegisterProfilePrefs( |
| 130 user_prefs::PrefRegistrySyncable* registry) {} | 130 user_prefs::PrefRegistrySyncable* registry) {} |
| 131 | 131 |
| 132 // KeyedServiceFactory: | 132 // KeyedServiceFactory: |
| 133 KeyedService* BuildServiceInstanceFor( | 133 scoped_ptr<KeyedService> BuildServiceInstanceFor( |
| 134 base::SupportsUserData* context) const final; | 134 base::SupportsUserData* context) const final; |
| 135 bool IsOffTheRecord(base::SupportsUserData* context) const final; | 135 bool IsOffTheRecord(base::SupportsUserData* context) const final; |
| 136 | 136 |
| 137 // KeyedServiceBaseFactory: | 137 // KeyedServiceBaseFactory: |
| 138 base::SupportsUserData* GetContextToUse( | 138 base::SupportsUserData* GetContextToUse( |
| 139 base::SupportsUserData* context) const final; | 139 base::SupportsUserData* context) const final; |
| 140 bool ServiceIsCreatedWithContext() const final; | 140 bool ServiceIsCreatedWithContext() const final; |
| 141 void ContextShutdown(base::SupportsUserData* context) final; | 141 void ContextShutdown(base::SupportsUserData* context) final; |
| 142 void ContextDestroyed(base::SupportsUserData* context) final; | 142 void ContextDestroyed(base::SupportsUserData* context) final; |
| 143 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) final; | 143 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) final; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); | 145 DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTOR
Y_H_ | 148 #endif // COMPONENTS_KEYED_SERVICE_CONTENT_BROWSER_CONTEXT_KEYED_SERVICE_FACTOR
Y_H_ |
| OLD | NEW |