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

Unified Diff: chrome/browser/profiles/profile_keyed_service_factory.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_keyed_service_factory.cc
diff --git a/chrome/browser/profiles/profile_keyed_service_factory.cc b/chrome/browser/profiles/profile_keyed_service_factory.cc
index 755409e28257057567530e22b8f071cb5bfc67eb..851571432603e4fc1bbc4b9c470226ac3b43f258 100644
--- a/chrome/browser/profiles/profile_keyed_service_factory.cc
+++ b/chrome/browser/profiles/profile_keyed_service_factory.cc
@@ -23,7 +23,8 @@ ProfileKeyedServiceFactory::~ProfileKeyedServiceFactory() {
}
ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile(
- Profile* profile) {
+ Profile* profile,
+ bool create) {
// Possibly handle Incognito mode.
if (profile->IsOffTheRecord()) {
if (ServiceRedirectedInIncognito()) {
@@ -41,14 +42,18 @@ ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile(
mapping_.find(profile);
if (it != mapping_.end()) {
service = it->second;
- if (service || !factory_)
+ if (service || !factory_ || !create)
return service;
// service is NULL but we have a mock factory function
mapping_.erase(it);
service = factory_(profile);
- } else {
+ } else if (create) {
+ // not found but creation allowed
service = BuildServiceInstanceFor(profile);
+ } else {
+ // not found, creation forbidden
+ return NULL;
}
Associate(profile, service);
« no previous file with comments | « chrome/browser/profiles/profile_keyed_service_factory.h ('k') | chrome/browser/tabs/pinned_tab_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698