OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "chrome/browser/profiles/dependency_node.h" | 11 #include "chrome/browser/profiles/dependency_node.h" |
12 | 12 |
| 13 class PrefService; |
| 14 class Profile; |
| 15 class ProfileDependencyManager; |
| 16 |
13 namespace content { | 17 namespace content { |
14 class BrowserContext; | 18 class BrowserContext; |
15 }; | 19 } |
16 | 20 |
| 21 namespace user_prefs { |
17 class PrefRegistrySyncable; | 22 class PrefRegistrySyncable; |
18 class PrefService; | 23 } |
19 class ProfileDependencyManager; | |
20 | |
21 class Profile; | |
22 | |
23 // Base class for Factories that take a Profile object and return some service. | 24 // Base class for Factories that take a Profile object and return some service. |
24 // | 25 // |
25 // Unless you're trying to make a new type of Factory, you probably don't want | 26 // Unless you're trying to make a new type of Factory, you probably don't want |
26 // this class, but its subclasses: ProfileKeyedServiceFactory and | 27 // this class, but its subclasses: ProfileKeyedServiceFactory and |
27 // RefcountedProfileKeyedServiceFactory. This object describes general | 28 // RefcountedProfileKeyedServiceFactory. This object describes general |
28 // dependency management between Factories; subclasses react to lifecycle | 29 // dependency management between Factories; subclasses react to lifecycle |
29 // events and implement memory management. | 30 // events and implement memory management. |
30 class ProfileKeyedBaseFactory : public base::NonThreadSafe, | 31 class ProfileKeyedBaseFactory : public base::NonThreadSafe, |
31 public DependencyNode { | 32 public DependencyNode { |
32 public: | 33 public: |
(...skipping 19 matching lines...) Expand all Loading... |
52 | 53 |
53 // Interface for people building a concrete FooServiceFactory: -------------- | 54 // Interface for people building a concrete FooServiceFactory: -------------- |
54 | 55 |
55 // Finds which browser context (if any) to use. | 56 // Finds which browser context (if any) to use. |
56 virtual content::BrowserContext* GetBrowserContextToUse( | 57 virtual content::BrowserContext* GetBrowserContextToUse( |
57 content::BrowserContext* context) const; | 58 content::BrowserContext* context) const; |
58 | 59 |
59 // Register any user preferences on this service. This is called during | 60 // Register any user preferences on this service. This is called during |
60 // CreateProfileService() since preferences are registered on a per Profile | 61 // CreateProfileService() since preferences are registered on a per Profile |
61 // basis. | 62 // basis. |
62 virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) {} | 63 virtual void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry) {} |
63 | 64 |
64 // By default, we create instances of a service lazily and wait until | 65 // By default, we create instances of a service lazily and wait until |
65 // GetForProfile() is called on our subclass. Some services need to be | 66 // GetForProfile() is called on our subclass. Some services need to be |
66 // created as soon as the Profile has been brought up. | 67 // created as soon as the Profile has been brought up. |
67 virtual bool ServiceIsCreatedWithProfile() const; | 68 virtual bool ServiceIsCreatedWithProfile() const; |
68 | 69 |
69 // By default, TestingProfiles will be treated like normal profiles. You can | 70 // By default, TestingProfiles will be treated like normal profiles. You can |
70 // override this so that by default, the service associated with the | 71 // override this so that by default, the service associated with the |
71 // TestingProfile is NULL. (This is just a shortcut around | 72 // TestingProfile is NULL. (This is just a shortcut around |
72 // SetTestingFactory() to make sure our profiles don't directly refer to the | 73 // SetTestingFactory() to make sure our profiles don't directly refer to the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 125 |
125 #if !defined(NDEBUG) | 126 #if !defined(NDEBUG) |
126 // A static string passed in to our constructor. Should be unique across all | 127 // A static string passed in to our constructor. Should be unique across all |
127 // services. This is used only for debugging in debug mode. (We can print | 128 // services. This is used only for debugging in debug mode. (We can print |
128 // pretty graphs with GraphViz with this information.) | 129 // pretty graphs with GraphViz with this information.) |
129 const char* service_name_; | 130 const char* service_name_; |
130 #endif | 131 #endif |
131 }; | 132 }; |
132 | 133 |
133 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ | 134 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_BASE_FACTORY_H_ |
OLD | NEW |