Commit 57e9d18d authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Fix SetTestingFactoryAndUse for BSKSF

The documentation says that the parameter must not be empty, so
add a DCHECK instead of a check. This is safe as the underlying
method in KSF DCHECK too.

Bug: 809610
Change-Id: Ib7c8b15d1bbc3f82ee3403f530a0167020cfee53
Reviewed-on: https://chromium-review.googlesource.com/1248629Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594721}
parent 9d91df55
...@@ -28,17 +28,15 @@ void BrowserStateKeyedServiceFactory::SetTestingFactory( ...@@ -28,17 +28,15 @@ void BrowserStateKeyedServiceFactory::SetTestingFactory(
KeyedService* BrowserStateKeyedServiceFactory::SetTestingFactoryAndUse( KeyedService* BrowserStateKeyedServiceFactory::SetTestingFactoryAndUse(
web::BrowserState* context, web::BrowserState* context,
TestingFactory testing_factory) { TestingFactory testing_factory) {
KeyedServiceFactory::TestingFactory wrapped_factory; DCHECK(testing_factory);
if (testing_factory) {
wrapped_factory = base::BindRepeating(
[](const TestingFactory& testing_factory,
base::SupportsUserData* context) {
return testing_factory.Run(static_cast<web::BrowserState*>(context));
},
std::move(testing_factory));
}
return KeyedServiceFactory::SetTestingFactoryAndUse( return KeyedServiceFactory::SetTestingFactoryAndUse(
context, std::move(wrapped_factory)); context, base::BindRepeating(
[](const TestingFactory& testing_factory,
base::SupportsUserData* context) {
return testing_factory.Run(
static_cast<web::BrowserState*>(context));
},
std::move(testing_factory)));
} }
BrowserStateKeyedServiceFactory::BrowserStateKeyedServiceFactory( BrowserStateKeyedServiceFactory::BrowserStateKeyedServiceFactory(
......
...@@ -30,17 +30,15 @@ scoped_refptr<RefcountedKeyedService> ...@@ -30,17 +30,15 @@ scoped_refptr<RefcountedKeyedService>
RefcountedBrowserStateKeyedServiceFactory::SetTestingFactoryAndUse( RefcountedBrowserStateKeyedServiceFactory::SetTestingFactoryAndUse(
web::BrowserState* context, web::BrowserState* context,
TestingFactory testing_factory) { TestingFactory testing_factory) {
RefcountedKeyedServiceFactory::TestingFactory wrapped_factory; DCHECK(testing_factory);
if (testing_factory) {
wrapped_factory = base::BindRepeating(
[](const TestingFactory& testing_factory,
base::SupportsUserData* context) {
return testing_factory.Run(static_cast<web::BrowserState*>(context));
},
std::move(testing_factory));
}
return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse( return RefcountedKeyedServiceFactory::SetTestingFactoryAndUse(
context, std::move(wrapped_factory)); context, base::BindRepeating(
[](const TestingFactory& testing_factory,
base::SupportsUserData* context) {
return testing_factory.Run(
static_cast<web::BrowserState*>(context));
},
std::move(testing_factory)));
} }
RefcountedBrowserStateKeyedServiceFactory:: RefcountedBrowserStateKeyedServiceFactory::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment