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

Convert indirect uses of TestingFactoryFunction

TestingFactoryFunction is a simple function pointer. It is
deprecated in favor of TestingFactory which is a Callback<>.
Convert indirect uses by using base::BindRepeating() in all
invocation of SetTestingFactory/AddTestingFactory.

This converts uses in src//chrome/browser/push_messaging.

This CL was uploaded by git cl split.

R=mvanouwerkerk@chromium.org

Bug: 809610
Change-Id: Ib8ccd8e3763c2c8172b9d7dcb7dac3cbc5e8e809
Reviewed-on: https://chromium-review.googlesource.com/c/1261699Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597076}
parent b3fa2dfe
......@@ -182,8 +182,8 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
// Calls should be wrapped in the ASSERT_NO_FATAL_FAILURE() macro.
void RestartPushService() {
Profile* profile = GetBrowser()->profile();
PushMessagingServiceFactory::GetInstance()->SetTestingFactory(profile,
nullptr);
PushMessagingServiceFactory::GetInstance()->SetTestingFactory(
profile, BrowserContextKeyedServiceFactory::TestingFactory());
ASSERT_EQ(nullptr, PushMessagingServiceFactory::GetForProfile(profile));
PushMessagingServiceFactory::GetInstance()->RestoreFactoryForTests(profile);
PushMessagingServiceImpl::InitializeForProfile(profile);
......
......@@ -6,6 +6,8 @@
#include <memory>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/engagement/site_engagement_service_factory.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h"
......@@ -56,10 +58,11 @@ PushMessagingServiceFactory::~PushMessagingServiceFactory() {}
void PushMessagingServiceFactory::RestoreFactoryForTests(
content::BrowserContext* context) {
SetTestingFactory(context, [](content::BrowserContext* context) {
return std::unique_ptr<KeyedService>(
GetInstance()->BuildServiceInstanceFor(context));
});
SetTestingFactory(context,
base::BindRepeating([](content::BrowserContext* context) {
return base::WrapUnique(
GetInstance()->BuildServiceInstanceFor(context));
}));
}
KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor(
......
......@@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/run_loop.h"
......@@ -97,7 +98,7 @@ class PushMessagingServiceTest : public ::testing::Test {
// Override the GCM Profile service so that we can send fake messages.
gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactory(
&profile_, &BuildFakeGCMProfileService);
&profile_, base::BindRepeating(&BuildFakeGCMProfileService));
}
~PushMessagingServiceTest() 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