| Index: chrome/browser/profiles/profile_keyed_base_factory.h
|
| diff --git a/chrome/browser/profiles/profile_keyed_base_factory.h b/chrome/browser/profiles/profile_keyed_base_factory.h
|
| index efd1edd5bd69b8f3f375a4e37d97fa7ffb4f7d88..fd8ef87002d06834ee7675d9e2ba67f709b787d4 100644
|
| --- a/chrome/browser/profiles/profile_keyed_base_factory.h
|
| +++ b/chrome/browser/profiles/profile_keyed_base_factory.h
|
| @@ -12,37 +12,17 @@
|
|
|
| class PrefService;
|
| class Profile;
|
| -class ProfileKeyedBase;
|
| class ProfileDependencyManager;
|
|
|
| // Base class for Factories that take a Profile object and return some service.
|
| //
|
| // Unless you're trying to make a new type of Factory, you probably don't want
|
| // this class, but its subclasses: ProfileKeyedServiceFactory and
|
| -// RefcountedProfileKeyedServiceFactory. This object describes general profile
|
| -// dependency management; subclasses react to lifecycle events and implement
|
| -// memory management.
|
| +// RefcountedProfileKeyedServiceFactory. This object describes general
|
| +// dependency management between Factories; subclasses react to lifecycle
|
| +// events and implement memory management.
|
| class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
| public:
|
| - // A function that replaces the (possibly internal) object used by this
|
| - // factory. For the majority of cases, this is the object returned to users.
|
| - typedef ProfileKeyedBase* (*FactoryFunction)(Profile* 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. A
|
| - // second call to SetTestingFactory() is allowed. If the FactoryFunction is
|
| - // changed AND an instance of the PKSF already exists for |profile|, that
|
| - // service is destroyed.
|
| - void SetTestingFactory(Profile* profile, FactoryFunction factory);
|
| -
|
| - // Associates |factory| with |profile| and immediately returns the created
|
| - // ProfileKeyedService. Since the factory will be used immediately, it may
|
| - // not be NULL;
|
| - ProfileKeyedBase* SetTestingFactoryAndUse(Profile* profile,
|
| - FactoryFunction factory);
|
| -
|
| // Registers preferences used in this service on the pref service of
|
| // |profile|. This is the public interface and is safe to be called multiple
|
| // times because testing code can have multiple services of the same type
|
| @@ -70,6 +50,9 @@ class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
| // created by factories.
|
| void DependsOn(ProfileKeyedBaseFactory* rhs);
|
|
|
| + // Finds which profile (if any) to use using the Service.*Incognito methods.
|
| + Profile* GetProfileToUse(Profile* profile);
|
| +
|
| // Interface for people building a concrete FooServiceFactory: --------------
|
|
|
| // Register any user preferences on this service. This is called during
|
| @@ -77,11 +60,6 @@ class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
| // basis.
|
| virtual void RegisterUserPrefs(PrefService* user_prefs) {}
|
|
|
| - // Returns a new instance of the service, casted to our void* equivalent for
|
| - // our storage.
|
| - virtual ProfileKeyedBase* BuildServiceInstanceFor(
|
| - Profile* profile) const = 0;
|
| -
|
| // By default, if we are asked for a service with an Incognito profile, we
|
| // pass back NULL. To redirect to the Incognito's original profile or to
|
| // create another instance, even for Incognito windows, override one of the
|
| @@ -103,23 +81,6 @@ class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
|
|
| // Interface for people building a type of ProfileKeyedFactory: -------------
|
|
|
| - // Common implementation that maps |profile| to some object. Deals with
|
| - // incognito profiles per subclass instructions with
|
| - // ServiceRedirectedInIncognito() and ServiceHasOwnInstanceInIncognito().
|
| - // If |create| is true, the service will be created using
|
| - // BuildServiceInstanceFor() if it doesn't already exist.
|
| - virtual ProfileKeyedBase* GetBaseForProfile(Profile* profile,
|
| - bool create);
|
| -
|
| - // The base factory is not responsible for storage; the derived factory type
|
| - // maintains storage and reacts to lifecycle events.
|
| - virtual void Associate(Profile* profile, ProfileKeyedBase* base) = 0;
|
| -
|
| - // Returns whether there is an object associated with |profile|. If |out| is
|
| - // non-NULL, returns said object.
|
| - virtual bool GetAssociation(Profile* profile,
|
| - ProfileKeyedBase** out) const = 0;
|
| -
|
| // A helper object actually listens for notifications about Profile
|
| // destruction, calculates the order in which things are destroyed and then
|
| // does a two pass shutdown.
|
| @@ -138,10 +99,28 @@ class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
| virtual void ProfileShutdown(Profile* profile) = 0;
|
| virtual void ProfileDestroyed(Profile* profile);
|
|
|
| + protected:
|
| + // Returns whether we've registered the preferences on this profile.
|
| + bool ArePreferencesSetOn(Profile* profile);
|
| +
|
| + // Mark profile as Preferences set.
|
| + void MarkPreferencesSetOn(Profile* profile);
|
| +
|
| private:
|
| friend class ProfileDependencyManager;
|
| friend class ProfileDependencyManagerUnittests;
|
|
|
| + // These two methods are for tight integration with the
|
| + // ProfileDependencyManager.
|
| +
|
| + // Because of ServiceIsNULLWhileTesting(), we need a way to tell different
|
| + // subclasses that they should disable testing.
|
| + virtual void SetEmptyTestingFactory(Profile* profile) = 0;
|
| +
|
| + // We also need a generalized, non-returning method that generates the object
|
| + // now for when we're creating the profile.
|
| + virtual void CreateServiceNow(Profile* profile) = 0;
|
| +
|
| // Which ProfileDependencyManager we should communicate with. In real code,
|
| // this will always be ProfileDependencyManager::GetInstance(), but unit
|
| // tests will want to use their own copy.
|
| @@ -150,9 +129,6 @@ class ProfileKeyedBaseFactory : public base::NonThreadSafe {
|
| // Profiles that have this service's preferences registered on them.
|
| std::set<Profile*> registered_preferences_;
|
|
|
| - // The mapping between a Profile and its overridden FactoryFunction.
|
| - std::map<Profile*, FactoryFunction> factories_;
|
| -
|
| #if !defined(NDEBUG)
|
| // A static string passed in to our constructor. Should be unique across all
|
| // services. This is used only for debugging in debug mode. (We can print
|
|
|