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