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

Unified Diff: components/keyed_service/core/keyed_service_factory.cc

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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: components/keyed_service/core/keyed_service_factory.cc
diff --git a/components/keyed_service/core/keyed_service_factory.cc b/components/keyed_service/core/keyed_service_factory.cc
index 1417bab80a39e88278147bd333e60854f13f5890..efc61f904e7b8bc1631e97fff4038afd499c9f1f 100644
--- a/components/keyed_service/core/keyed_service_factory.cc
+++ b/components/keyed_service/core/keyed_service_factory.cc
@@ -77,7 +77,7 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
// Create new object.
// Check to see if we have a per-context testing factory that we should use
// instead of default behavior.
- KeyedService* service = nullptr;
+ scoped_ptr<KeyedService> service;
const auto& jt = testing_factories_.find(context);
if (jt != testing_factories_.end()) {
if (jt->second) {
@@ -89,14 +89,14 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
service = BuildServiceInstanceFor(context);
}
- Associate(context, service);
- return service;
+ Associate(context, service.Pass());
+ return mapping_[context];
}
void KeyedServiceFactory::Associate(base::SupportsUserData* context,
- KeyedService* service) {
+ scoped_ptr<KeyedService> service) {
DCHECK(!ContainsKey(mapping_, context));
- mapping_.insert(std::make_pair(context, service));
+ mapping_.insert(std::make_pair(context, service.release()));
}
void KeyedServiceFactory::Disassociate(base::SupportsUserData* context) {

Powered by Google App Engine
This is Rietveld 408576698