Index: components/browser_context_keyed_service/browser_context_keyed_service_factory.h |
diff --git a/components/browser_context_keyed_service/browser_context_keyed_service_factory.h b/components/browser_context_keyed_service/browser_context_keyed_service_factory.h |
index f222c42c993a036954400048f7a215a1e60ac6fc..0ce3a1db92be72c6f42532f11f25777a02120363 100644 |
--- a/components/browser_context_keyed_service/browser_context_keyed_service_factory.h |
+++ b/components/browser_context_keyed_service/browser_context_keyed_service_factory.h |
@@ -12,104 +12,109 @@ |
#include "components/browser_context_keyed_service/browser_context_keyed_base_factory.h" |
#include "components/browser_context_keyed_service/browser_context_keyed_service.h" |
-class ProfileDependencyManager; |
-class ProfileKeyedService; |
+class BrowserContextDependencyManager; |
+class BrowserContextKeyedService; |
-// Base class for Factories that take a Profile object and return some service |
-// on a one-to-one mapping. Each factory that derives from this class *must* |
-// be a Singleton (only unit tests don't do that). See ThemeServiceFactory as |
-// an example of how to derive from this class. |
+// Base class for Factories that take a BrowserContext object and return some |
+// service on a one-to-one mapping. Each factory that derives from this class |
+// *must* be a Singleton (only unit tests don't do that). |
// |
// We do this because services depend on each other and we need to control |
// shutdown/destruction order. In each derived classes' constructors, the |
// implementors must explicitly state which services are depended on. |
-class ProfileKeyedServiceFactory : public ProfileKeyedBaseFactory { |
+class BrowserContextKeyedServiceFactory |
+ : public BrowserContextKeyedBaseFactory { |
public: |
- // A function that supplies the instance of a ProfileKeyedService for a given |
- // Profile. This is used primarily for testing, where we want to feed a |
- // specific mock into the PKSF system. |
- typedef ProfileKeyedService* |
- (*FactoryFunction)(content::BrowserContext* profile); |
- |
- // Associates |factory| with |profile| so that |factory| is used to create |
- // the ProfileKeyedService when requested. |factory| can be NULL to signal |
- // that ProfileKeyedService should be NULL. Multiple calls to |
+ // A function that supplies the instance of a BrowserContextKeyedService |
+ // for a given BrowserContext. This is used primarily for testing, where |
+ // we want to feed a specific mock into the BCKSF system. |
+ typedef BrowserContextKeyedService* |
+ (*FactoryFunction)(content::BrowserContext* context); |
+ |
+ // Associates |factory| with |context| so that |factory| is used to create |
+ // the BrowserContextKeyedService when requested. |factory| can be NULL |
+ // to signal that BrowserContextKeyedService should be NULL. Multiple calls to |
// SetTestingFactory() are allowed; previous services will be shut down. |
- void SetTestingFactory(content::BrowserContext* profile, |
+ void SetTestingFactory(content::BrowserContext* context, |
FactoryFunction factory); |
- // Associates |factory| with |profile| and immediately returns the created |
- // ProfileKeyedService. Since the factory will be used immediately, it may |
- // not be NULL. |
- ProfileKeyedService* SetTestingFactoryAndUse(content::BrowserContext* profile, |
- FactoryFunction factory); |
+ // Associates |factory| with |context| and immediately returns the created |
+ // BrowserContextKeyedService. Since the factory will be used immediately, |
+ // it may not be NULL. |
+ BrowserContextKeyedService* SetTestingFactoryAndUse( |
+ content::BrowserContext* context, |
+ FactoryFunction factory); |
protected: |
- // ProfileKeyedServiceFactories must communicate with a |
- // ProfileDependencyManager. For all non-test code, write your subclass |
+ // BrowserContextKeyedServiceFactories must communicate with a |
+ // BrowserContextDependencyManager. For all non-test code, write your subclass |
// constructors like this: |
// |
// MyServiceFactory::MyServiceFactory() |
- // : ProfileKeyedServiceFactory( |
+ // : BrowserContextKeyedServiceFactory( |
// "MyService", |
- // ProfileDependencyManager::GetInstance()) |
+ // BrowserContextDependencyManager::GetInstance()) |
// {} |
- ProfileKeyedServiceFactory(const char* name, |
- ProfileDependencyManager* manager); |
- virtual ~ProfileKeyedServiceFactory(); |
+ BrowserContextKeyedServiceFactory(const char* name, |
+ BrowserContextDependencyManager* manager); |
+ virtual ~BrowserContextKeyedServiceFactory(); |
- // Common implementation that maps |profile| to some service object. Deals |
- // with incognito profiles per subclass instructions with |
+ // Common implementation that maps |context| to some service object. Deals |
+ // with incognito contexts per subclass instructions with |
// ServiceRedirectedInIncognito() and ServiceHasOwnInstanceInIncognito() |
- // through the GetProfileToUse() method on the base. If |create| is true, |
- // the service will be created using BuildServiceInstanceFor() if it doesn't |
- // already exist. |
- ProfileKeyedService* GetServiceForProfile(content::BrowserContext* profile, |
- bool create); |
- |
- // Maps |profile| to |service| with debug checks to prevent duplication. |
- void Associate(content::BrowserContext* profile, |
- ProfileKeyedService* service); |
- |
- // All subclasses of ProfileKeyedServiceFactory must return a |
- // ProfileKeyedService instead of just a ProfileKeyedBase. |
- virtual ProfileKeyedService* BuildServiceInstanceFor( |
- content::BrowserContext* profile) const = 0; |
- |
- // A helper object actually listens for notifications about Profile |
+ // through the GetBrowserContextToUse() method on the base. |
+ // If |create| is true, the service will be created using |
+ // BuildServiceInstanceFor() if it doesn't already exist. |
+ BrowserContextKeyedService* GetServiceForBrowserContext( |
+ content::BrowserContext* context, |
+ bool create); |
+ |
+ // Maps |context| to |service| with debug checks to prevent duplication. |
+ void Associate(content::BrowserContext* context, |
+ BrowserContextKeyedService* service); |
+ |
+ // All subclasses of BrowserContextKeyedServiceFactory must return a |
+ // BrowserContextKeyedService instead of just a BrowserContextKeyedBase. |
+ virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
+ content::BrowserContext* context) const = 0; |
+ |
+ // A helper object actually listens for notifications about BrowserContext |
// destruction, calculates the order in which things are destroyed and then |
// does a two pass shutdown. |
// |
- // First, ProfileShutdown() is called on every ServiceFactory and will |
- // usually call ProfileKeyedService::Shutdown(), which gives each |
- // ProfileKeyedService a chance to remove dependencies on other services that |
- // it may be holding. |
+ // First, BrowserContextShutdown() is called on every ServiceFactory and will |
+ // usually call BrowserContextKeyedService::Shutdown(), which gives each |
+ // BrowserContextKeyedService a chance to remove dependencies on other |
+ // services that it may be holding. |
// |
- // Secondly, ProfileDestroyed() is called on every ServiceFactory and the |
- // default implementation removes it from |mapping_| and deletes the pointer. |
- virtual void ProfileShutdown(content::BrowserContext* profile) OVERRIDE; |
- virtual void ProfileDestroyed(content::BrowserContext* profile) OVERRIDE; |
+ // Secondly, BrowserContextDestroyed() is called on every ServiceFactory |
+ // and the default implementation removes it from |mapping_| and deletes |
+ // the pointer. |
+ virtual void BrowserContextShutdown( |
+ content::BrowserContext* context) OVERRIDE; |
+ virtual void BrowserContextDestroyed( |
+ content::BrowserContext* context) OVERRIDE; |
virtual void SetEmptyTestingFactory( |
- content::BrowserContext* profile) OVERRIDE; |
- virtual void CreateServiceNow(content::BrowserContext* profile) OVERRIDE; |
+ content::BrowserContext* context) OVERRIDE; |
+ virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; |
private: |
- friend class ProfileDependencyManager; |
- friend class ProfileDependencyManagerUnittests; |
+ friend class BrowserContextDependencyManager; |
+ friend class BrowserContextDependencyManagerUnittests; |
- typedef std::map<content::BrowserContext*, ProfileKeyedService*> |
- ProfileKeyedServices; |
+ typedef std::map<content::BrowserContext*, BrowserContextKeyedService*> |
+ BrowserContextKeyedServices; |
typedef std::map<content::BrowserContext*, FactoryFunction> |
- ProfileOverriddenFunctions; |
+ BrowserContextOverriddenFunctions; |
- // The mapping between a Profile and its service. |
- std::map<content::BrowserContext*, ProfileKeyedService*> mapping_; |
+ // The mapping between a BrowserContext and its service. |
+ std::map<content::BrowserContext*, BrowserContextKeyedService*> mapping_; |
- // The mapping between a Profile and its overridden FactoryFunction. |
+ // The mapping between a BrowserContext and its overridden FactoryFunction. |
std::map<content::BrowserContext*, FactoryFunction> factories_; |
- DISALLOW_COPY_AND_ASSIGN(ProfileKeyedServiceFactory); |
+ DISALLOW_COPY_AND_ASSIGN(BrowserContextKeyedServiceFactory); |
}; |
#endif // COMPONENTS_BROWSER_CONTEXT_KEYED_SERVICE_BROWSER_CONTEXT_KEYED_SERVICE_FACTORY_H_ |