| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 class Profile; | 10 class Profile; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 virtual ProfileKeyedService* BuildServiceInstanceFor( | 68 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 69 Profile* profile) const = 0; | 69 Profile* profile) const = 0; |
| 70 | 70 |
| 71 // By default, if we are asked for a service with an Incognito profile, we | 71 // By default, if we are asked for a service with an Incognito profile, we |
| 72 // pass back NULL. To redirect to the Incognito's original profile or to | 72 // pass back NULL. To redirect to the Incognito's original profile or to |
| 73 // create another instance, even for Incognito windows, override one of the | 73 // create another instance, even for Incognito windows, override one of the |
| 74 // following methods: | 74 // following methods: |
| 75 virtual bool ServiceRedirectedInIncognito(); | 75 virtual bool ServiceRedirectedInIncognito(); |
| 76 virtual bool ServiceHasOwnInstanceInIncognito(); | 76 virtual bool ServiceHasOwnInstanceInIncognito(); |
| 77 | 77 |
| 78 // By default, we create instances of a service lazily and wait until |
| 79 // GetForProfile() is called on our subclass. Some services need to be |
| 80 // created as soon as the Profile has been brought up. |
| 81 virtual bool ServiceIsCreatedWithProfile(); |
| 82 |
| 83 // By default, TestingProfiles will be treated like normal profiles. You can |
| 84 // override this so that by default, the service associated with the |
| 85 // TestingProfile is NULL. (This is just a shortcut around |
| 86 // SetTestingFactory() to make sure our profiles don't directly refer to the |
| 87 // services they use.) |
| 88 virtual bool ServiceIsNULLWhileTesting(); |
| 89 |
| 78 // A helper object actually listens for notifications about Profile | 90 // A helper object actually listens for notifications about Profile |
| 79 // destruction, calculates the order in which things are destroyed and then | 91 // destruction, calculates the order in which things are destroyed and then |
| 80 // does a two pass shutdown. | 92 // does a two pass shutdown. |
| 81 // | 93 // |
| 82 // First, ProfileShutdown() is called on every ServiceFactory and will | 94 // First, ProfileShutdown() is called on every ServiceFactory and will |
| 83 // usually call ProfileKeyedService::Shutdown(), which gives each | 95 // usually call ProfileKeyedService::Shutdown(), which gives each |
| 84 // ProfileKeyedService a chance to remove dependencies on other services that | 96 // ProfileKeyedService a chance to remove dependencies on other services that |
| 85 // it may be holding. | 97 // it may be holding. |
| 86 // | 98 // |
| 87 // Secondly, ProfileDestroyed() is called on every ServiceFactory and the | 99 // Secondly, ProfileDestroyed() is called on every ServiceFactory and the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 99 // The mapping between a Profile and its overridden FactoryFunction. | 111 // The mapping between a Profile and its overridden FactoryFunction. |
| 100 std::map<Profile*, FactoryFunction> factories_; | 112 std::map<Profile*, FactoryFunction> factories_; |
| 101 | 113 |
| 102 // Which ProfileDependencyManager we should communicate with. In real code, | 114 // Which ProfileDependencyManager we should communicate with. In real code, |
| 103 // this will always be ProfileDependencyManager::GetInstance(), but unit | 115 // this will always be ProfileDependencyManager::GetInstance(), but unit |
| 104 // tests will want to use their own copy. | 116 // tests will want to use their own copy. |
| 105 ProfileDependencyManager* dependency_manager_; | 117 ProfileDependencyManager* dependency_manager_; |
| 106 }; | 118 }; |
| 107 | 119 |
| 108 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ | 120 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ |
| OLD | NEW |