Commit 82b5e9aa authored by Anna Malova's avatar Anna Malova Committed by Commit Bot

Convert DnsConfigServicePosix to use RepeatingCallback.

Bug: 1007815
Change-Id: I14f5647a693f63d63ffa457190e02dac0727ef00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089756
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747313}
parent 12f35d22
......@@ -60,7 +60,7 @@ const base::FilePath::CharType kFilePathHosts[] =
// There is no public API to watch the DNS configuration on iOS.
class DnsConfigWatcher {
public:
using CallbackType = base::Callback<void(bool succeeded)>;
using CallbackType = base::RepeatingCallback<void(bool succeeded)>;
bool Watch(const CallbackType& callback) {
return false;
......@@ -78,7 +78,7 @@ class DnsConfigWatcher : public NetworkChangeNotifier::NetworkChangeObserver {
NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
}
using CallbackType = base::Callback<void(bool succeeded)>;
using CallbackType = base::RepeatingCallback<void(bool succeeded)>;
bool Watch(const CallbackType& callback) {
callback_ = callback;
......@@ -110,12 +110,12 @@ const base::FilePath::CharType kFilePathConfig[] =
class DnsConfigWatcher {
public:
using CallbackType = base::Callback<void(bool succeeded)>;
using CallbackType = base::RepeatingCallback<void(bool succeeded)>;
bool Watch(const CallbackType& callback) {
callback_ = callback;
return watcher_.Watch(base::FilePath(kFilePathConfig), false,
base::Bind(&DnsConfigWatcher::OnCallback,
base::BindRepeating(&DnsConfigWatcher::OnCallback,
base::Unretained(this)));
}
......@@ -246,7 +246,7 @@ class DnsConfigServicePosix::Watcher {
bool Watch() {
bool success = true;
if (!config_watcher_.Watch(base::Bind(&Watcher::OnConfigChanged,
if (!config_watcher_.Watch(base::BindRepeating(&Watcher::OnConfigChanged,
base::Unretained(this)))) {
LOG(ERROR) << "DNS config watch failed to start.";
success = false;
......@@ -257,9 +257,9 @@ class DnsConfigServicePosix::Watcher {
// Hosts file should never change on Android or iOS (and watching it on Android
// is problematic; see http://crbug.com/600442), so don't watch it there.
#if !defined(OS_ANDROID) && !defined(OS_IOS)
if (!hosts_watcher_.Watch(
base::FilePath(service_->file_path_hosts_), false,
base::Bind(&Watcher::OnHostsChanged, base::Unretained(this)))) {
if (!hosts_watcher_.Watch(base::FilePath(service_->file_path_hosts_), false,
base::BindRepeating(&Watcher::OnHostsChanged,
base::Unretained(this)))) {
LOG(ERROR) << "DNS hosts watch failed to start.";
success = false;
UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus",
......
......@@ -252,8 +252,8 @@ class DnsConfigServicePosixTest : public testing::Test {
// Regression test for https://crbug.com/704662.
TEST_F(DnsConfigServicePosixTest, ChangeConfigMultipleTimes) {
service_->WatchConfig(base::Bind(&DnsConfigServicePosixTest::OnConfigChanged,
base::Unretained(this)));
service_->WatchConfig(base::BindRepeating(
&DnsConfigServicePosixTest::OnConfigChanged, base::Unretained(this)));
task_environment_.RunUntilIdle();
for (int i = 0; i < 5; i++) {
......
......@@ -70,7 +70,7 @@ namespace net {
namespace internal {
bool DnsConfigWatcher::Watch(
const base::Callback<void(bool succeeded)>& callback) {
const base::RepeatingCallback<void(bool succeeded)>& callback) {
if (!GetDnsInfoApi().dns_configuration_notify_key)
return false;
return watcher_.Watch(GetDnsInfoApi().dns_configuration_notify_key(),
......
......@@ -15,7 +15,7 @@ namespace internal {
// Watches DNS configuration on Mac.
class DnsConfigWatcher {
public:
bool Watch(const base::Callback<void(bool succeeded)>& callback);
bool Watch(const base::RepeatingCallback<void(bool succeeded)>& callback);
// Returns an error if the DNS configuration is invalid.
// Returns CONFIG_PARSE_POSIX_OK otherwise.
......
......@@ -18,7 +18,7 @@ namespace net {
class NotifyWatcherMac {
public:
// Called on received notification with true on success and false on error.
typedef base::Callback<void(bool succeeded)> CallbackType;
typedef base::RepeatingCallback<void(bool succeeded)> CallbackType;
NotifyWatcherMac();
......
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