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

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

Issue 1090373003: Allow cross dependencies between BCKSF and BSKSF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dependencies and DCHECK in Get{Original,Underlying}ContextInternal Created 5 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: 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..17d694f1fafb100c9100881f23debbd50fde2363 100644
--- a/components/keyed_service/core/keyed_service_factory.cc
+++ b/components/keyed_service/core/keyed_service_factory.cc
@@ -22,6 +22,7 @@ KeyedServiceFactory::~KeyedServiceFactory() {
void KeyedServiceFactory::SetTestingFactory(
base::SupportsUserData* context,
TestingFactoryFunction testing_factory) {
+ context = GetUnderlyingContext(context);
Elliot Glaysher 2015/04/21 17:54:32 This seems like it could be very error prone. Is t
sdefresne 2015/04/22 08:53:15 Yes, all calls to GetUnderlyingContext/GetOriginal
Elliot Glaysher 2015/04/22 17:34:07 Thanks, that sounds like a good plan.
// Destroying the context may cause us to lose data about whether |context|
// has our preferences registered on it (since the context object itself
// isn't dead). See if we need to readd it once we've gone through normal
@@ -52,6 +53,7 @@ KeyedService* KeyedServiceFactory::SetTestingFactoryAndUse(
base::SupportsUserData* context,
TestingFactoryFunction testing_factory) {
DCHECK(testing_factory);
+ context = GetUnderlyingContext(context);
SetTestingFactory(context, testing_factory);
return GetServiceForContext(context, true);
}
@@ -60,6 +62,7 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
base::SupportsUserData* context,
bool create) {
TRACE_EVENT0("browser,startup", "KeyedServiceFactory::GetServiceForContext");
+ context = GetUnderlyingContext(context);
context = GetContextToUse(context);
if (!context)
return nullptr;
@@ -95,11 +98,13 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
void KeyedServiceFactory::Associate(base::SupportsUserData* context,
KeyedService* service) {
+ context = GetUnderlyingContext(context);
DCHECK(!ContainsKey(mapping_, context));
mapping_.insert(std::make_pair(context, service));
}
void KeyedServiceFactory::Disassociate(base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
const auto& it = mapping_.find(context);
if (it != mapping_.end()) {
delete it->second;
@@ -108,12 +113,14 @@ void KeyedServiceFactory::Disassociate(base::SupportsUserData* context) {
}
void KeyedServiceFactory::ContextShutdown(base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
const auto& it = mapping_.find(context);
if (it != mapping_.end() && it->second)
it->second->Shutdown();
}
void KeyedServiceFactory::ContextDestroyed(base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
Disassociate(context);
// For unit tests, we also remove the factory function both so we don't
@@ -127,13 +134,16 @@ void KeyedServiceFactory::ContextDestroyed(base::SupportsUserData* context) {
void KeyedServiceFactory::SetEmptyTestingFactory(
base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
SetTestingFactory(context, nullptr);
}
bool KeyedServiceFactory::HasTestingFactory(base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
return testing_factories_.find(context) != testing_factories_.end();
}
void KeyedServiceFactory::CreateServiceNow(base::SupportsUserData* context) {
+ context = GetUnderlyingContext(context);
GetServiceForContext(context, true);
}

Powered by Google App Engine
This is Rietveld 408576698