| 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 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 5 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 : ProfileKeyedBaseFactory(name, manager) { | 45 : ProfileKeyedBaseFactory(name, manager) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 ProfileKeyedServiceFactory::~ProfileKeyedServiceFactory() { | 48 ProfileKeyedServiceFactory::~ProfileKeyedServiceFactory() { |
| 49 DCHECK(mapping_.empty()); | 49 DCHECK(mapping_.empty()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile( | 52 ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile( |
| 53 content::BrowserContext* profile, | 53 content::BrowserContext* profile, |
| 54 bool create) { | 54 bool create) { |
| 55 profile = GetProfileToUse(profile); | 55 profile = GetBrowserContextToUse(profile); |
| 56 if (!profile) | 56 if (!profile) |
| 57 return NULL; | 57 return NULL; |
| 58 | 58 |
| 59 // NOTE: If you modify any of the logic below, make sure to update the | 59 // NOTE: If you modify any of the logic below, make sure to update the |
| 60 // refcounted version in refcounted_profile_keyed_service_factory.cc! | 60 // refcounted version in refcounted_profile_keyed_service_factory.cc! |
| 61 ProfileKeyedServices::const_iterator it = mapping_.find(profile); | 61 ProfileKeyedServices::const_iterator it = mapping_.find(profile); |
| 62 if (it != mapping_.end()) | 62 if (it != mapping_.end()) |
| 63 return it->second; | 63 return it->second; |
| 64 | 64 |
| 65 // Object not found. | 65 // Object not found. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 void ProfileKeyedServiceFactory::SetEmptyTestingFactory( | 118 void ProfileKeyedServiceFactory::SetEmptyTestingFactory( |
| 119 content::BrowserContext* profile) { | 119 content::BrowserContext* profile) { |
| 120 SetTestingFactory(profile, NULL); | 120 SetTestingFactory(profile, NULL); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ProfileKeyedServiceFactory::CreateServiceNow( | 123 void ProfileKeyedServiceFactory::CreateServiceNow( |
| 124 content::BrowserContext* profile) { | 124 content::BrowserContext* profile) { |
| 125 GetServiceForProfile(profile, true); | 125 GetServiceForProfile(profile, true); |
| 126 } | 126 } |
| OLD | NEW |