Commit f5bfe410 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert ProfileInvalidationProviderFactory to TestingFactory

TestingFactory is a base::Callback<> while TestingFactoryFunction
is a function pointer. Convert ProfileInvalidationProviderFactory
to the callback based type.

Bug: 809610
Change-Id: Id6ddc4e75960f5fd1ed952877d4bebdca515b706
Reviewed-on: https://chromium-review.googlesource.com/c/1246166Reviewed-by: default avatarBartosz Fabianowski <bartfab@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597058}
parent 56dd83c9
......@@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
......@@ -212,7 +213,8 @@ void AffiliatedInvalidationServiceProviderImplTest::SetUp() {
TestingBrowserProcess::GetGlobal()->local_state());
invalidation::DeprecatedProfileInvalidationProviderFactory::GetInstance()
->RegisterTestingFactory(BuildProfileInvalidationProvider);
->RegisterTestingFactory(
base::BindRepeating(&BuildProfileInvalidationProvider));
provider_ = std::make_unique<AffiliatedInvalidationServiceProviderImpl>();
}
......@@ -224,7 +226,8 @@ void AffiliatedInvalidationServiceProviderImplTest::TearDown() {
test_shared_loader_factory_->Detach();
invalidation::DeprecatedProfileInvalidationProviderFactory::GetInstance()
->RegisterTestingFactory(nullptr);
->RegisterTestingFactory(
BrowserContextKeyedServiceFactory::TestingFactory());
chromeos::DeviceOAuth2TokenServiceFactory::Shutdown();
chromeos::DBusThreadManager::Shutdown();
chromeos::SystemSaltGetter::Shutdown();
......
......@@ -82,8 +82,7 @@ DeprecatedProfileInvalidationProviderFactory::
DeprecatedProfileInvalidationProviderFactory()
: BrowserContextKeyedServiceFactory(
"InvalidationService",
BrowserContextDependencyManager::GetInstance()),
testing_factory_(NULL) {
BrowserContextDependencyManager::GetInstance()) {
#if !defined(OS_ANDROID)
DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
......@@ -94,15 +93,15 @@ DeprecatedProfileInvalidationProviderFactory::
~DeprecatedProfileInvalidationProviderFactory() {}
void DeprecatedProfileInvalidationProviderFactory::RegisterTestingFactory(
TestingFactoryFunction testing_factory) {
testing_factory_ = testing_factory;
TestingFactory testing_factory) {
testing_factory_ = std::move(testing_factory);
}
KeyedService*
DeprecatedProfileInvalidationProviderFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
if (testing_factory_)
return testing_factory_(context).release();
return testing_factory_.Run(context).release();
#if defined(OS_ANDROID)
// Android does not need an IdentityProvider, because it gets the account
......
......@@ -40,7 +40,7 @@ class DeprecatedProfileInvalidationProviderFactory
// Switches service creation to go through |testing_factory| for all browser
// contexts.
void RegisterTestingFactory(TestingFactoryFunction testing_factory);
void RegisterTestingFactory(TestingFactory testing_factory);
private:
friend class DeprecatedProfileInvalidationProviderFactoryTestBase;
......@@ -57,7 +57,7 @@ class DeprecatedProfileInvalidationProviderFactory
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
TestingFactoryFunction testing_factory_;
TestingFactory testing_factory_;
DISALLOW_COPY_AND_ASSIGN(DeprecatedProfileInvalidationProviderFactory);
};
......
......@@ -80,8 +80,7 @@ ProfileInvalidationProviderFactory::GetInstance() {
ProfileInvalidationProviderFactory::ProfileInvalidationProviderFactory()
: BrowserContextKeyedServiceFactory(
"InvalidationService",
BrowserContextDependencyManager::GetInstance()),
testing_factory_(NULL) {
BrowserContextDependencyManager::GetInstance()) {
#if !defined(OS_ANDROID)
DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
......@@ -92,14 +91,14 @@ ProfileInvalidationProviderFactory::~ProfileInvalidationProviderFactory() =
default;
void ProfileInvalidationProviderFactory::RegisterTestingFactory(
TestingFactoryFunction testing_factory) {
testing_factory_ = testing_factory;
TestingFactory testing_factory) {
testing_factory_ = std::move(testing_factory);
}
KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
if (testing_factory_)
return testing_factory_(context).release();
return testing_factory_.Run(context).release();
#if defined(OS_ANDROID)
// Android does not need an IdentityProvider, because it gets the account
......
......@@ -36,7 +36,7 @@ class ProfileInvalidationProviderFactory
// Switches service creation to go through |testing_factory| for all browser
// contexts.
void RegisterTestingFactory(TestingFactoryFunction testing_factory);
void RegisterTestingFactory(TestingFactory testing_factory);
private:
friend class ProfileInvalidationProviderFactoryTestBase;
......@@ -51,7 +51,7 @@ class ProfileInvalidationProviderFactory
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
TestingFactoryFunction testing_factory_;
TestingFactory testing_factory_;
DISALLOW_COPY_AND_ASSIGN(ProfileInvalidationProviderFactory);
};
......
......@@ -4,6 +4,7 @@
#include <memory>
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
......@@ -202,7 +203,8 @@ class CloudPolicyTest : public InProcessBrowserTest,
command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url);
invalidation::DeprecatedProfileInvalidationProviderFactory::GetInstance()
->RegisterTestingFactory(BuildFakeProfileInvalidationProvider);
->RegisterTestingFactory(
base::BindRepeating(&BuildFakeProfileInvalidationProvider));
}
void SetUpOnMainThread() override {
......
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