Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/profiles/profile_keyed_service_factory.h

Issue 6879031: Add optional creation to ProfileKeyedServiceFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add docs for new parameter Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // 46 //
47 // MyServiceFactory::MyServiceFactory() 47 // MyServiceFactory::MyServiceFactory()
48 // : ProfileKeyedServiceFactory( 48 // : ProfileKeyedServiceFactory(
49 // ProfileDependencyManager::GetInstance()) 49 // ProfileDependencyManager::GetInstance())
50 // {} 50 // {}
51 explicit ProfileKeyedServiceFactory(ProfileDependencyManager* manager); 51 explicit ProfileKeyedServiceFactory(ProfileDependencyManager* manager);
52 virtual ~ProfileKeyedServiceFactory(); 52 virtual ~ProfileKeyedServiceFactory();
53 53
54 // Common implementation that maps |profile| to some service object. Deals 54 // Common implementation that maps |profile| to some service object. Deals
55 // with incognito profiles per subclass instructions with 55 // with incognito profiles per subclass instructions with
56 // ServiceActiveInIncognito(). 56 // ServiceActiveInIncognito(). If |create| is true, the service will be
57 ProfileKeyedService* GetServiceForProfile(Profile* profile); 57 // created using BuildServiceInstanceFor() if it doesn't already exist.
58 ProfileKeyedService* GetServiceForProfile(Profile* profile, bool create);
58 59
59 // The main public interface for declaring dependencies between services 60 // The main public interface for declaring dependencies between services
60 // created by factories. 61 // created by factories.
61 void DependsOn(ProfileKeyedServiceFactory* rhs); 62 void DependsOn(ProfileKeyedServiceFactory* rhs);
62 63
63 // Maps |profile| to |provider| with debug checks to prevent duplication. 64 // Maps |profile| to |provider| with debug checks to prevent duplication.
64 void Associate(Profile* profile, ProfileKeyedService* service); 65 void Associate(Profile* profile, ProfileKeyedService* service);
65 66
66 // Returns a new instance of the service, casted to void* for our common 67 // Returns a new instance of the service, casted to void* for our common
67 // storage. 68 // storage.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Which ProfileDependencyManager we should communicate with. In real code, 100 // Which ProfileDependencyManager we should communicate with. In real code,
100 // this will always be ProfileDependencyManager::GetInstance(), but unit 101 // this will always be ProfileDependencyManager::GetInstance(), but unit
101 // tests will want to use their own copy. 102 // tests will want to use their own copy.
102 ProfileDependencyManager* dependency_manager_; 103 ProfileDependencyManager* dependency_manager_;
103 104
104 // A mock factory function to use to create the service, used by tests. 105 // A mock factory function to use to create the service, used by tests.
105 FactoryFunction factory_; 106 FactoryFunction factory_;
106 }; 107 };
107 108
108 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_ 109 #endif // CHROME_BROWSER_PROFILES_PROFILE_KEYED_SERVICE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698