Chromium Code Reviews| Index: chrome/browser/profiles/profile_keyed_service_factory.h |
| diff --git a/chrome/browser/profiles/profile_keyed_service_factory.h b/chrome/browser/profiles/profile_keyed_service_factory.h |
| index fd33b150b11854d5d33a9f822efc9d124b5bb46a..632dc46bc048db6f2690952848b24c278da3906e 100644 |
| --- a/chrome/browser/profiles/profile_keyed_service_factory.h |
| +++ b/chrome/browser/profiles/profile_keyed_service_factory.h |
| @@ -20,10 +20,16 @@ class ProfileKeyedService; |
| // shutdown/destruction order. In each derived classes' constructors, the |
| // implementors must explicitly state which services are depended on. |
| class ProfileKeyedServiceFactory { |
| - protected: |
| - friend class ProfileDependencyManager; |
| - friend class ProfileDependencyManagerUnittests; |
| + public: |
| + typedef ProfileKeyedService* (*FactoryFunction)(Profile* profile); |
| +#if defined(UNIT_TEST) |
| + // Sets the factory which will be used by |GetServiceFunction|. A value of |
| + // NULL (the default) results in a call to |BuildServiceInstanceFor|. |
| + void set_factory_function(FactoryFunction factory) { factory_ = factory; } |
|
Elliot Glaysher
2011/04/08 17:43:32
This is fine, but I'm worried that there isn't an
Torne
2011/04/11 11:52:51
I was assuming that test code does not create norm
|
| +#endif |
| + |
| + protected: |
| // ProfileKeyedServiceFactories must communicate with a |
| // ProfileDependencyManager. For all non-test code, write your subclass |
| // constructors like this: |
| @@ -74,6 +80,9 @@ class ProfileKeyedServiceFactory { |
| virtual void ProfileDestroyed(Profile* profile); |
| private: |
| + friend class ProfileDependencyManager; |
| + friend class ProfileDependencyManagerUnittests; |
| + |
| // The mapping between a Profile and its service. |
| std::map<Profile*, ProfileKeyedService*> mapping_; |
| @@ -81,6 +90,9 @@ class ProfileKeyedServiceFactory { |
| // this will always be ProfileDependencyManager::GetInstance(), but unit |
| // tests will want to use their own copy. |
| ProfileDependencyManager* dependency_manager_; |
| + |
| + // An alternative function to use to create the service, used by tests. |
| + FactoryFunction factory_; |
| }; |
| #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ |