Commit 70405149 authored by Anna Malova's avatar Anna Malova Committed by Commit Bot

Convert DnsConfigService to use RepeatingCallback.

Bug: 1007815
Change-Id: I2eef21c585df6441715e188fcc816735b125b828
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091532
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747929}
parent aa6fd572
...@@ -27,7 +27,7 @@ class NET_EXPORT_PRIVATE DnsConfigService { ...@@ -27,7 +27,7 @@ class NET_EXPORT_PRIVATE DnsConfigService {
public: public:
// Callback interface for the client, called on the same thread as // Callback interface for the client, called on the same thread as
// ReadConfig() and WatchConfig(). // ReadConfig() and WatchConfig().
typedef base::Callback<void(const DnsConfig& config)> CallbackType; typedef base::RepeatingCallback<void(const DnsConfig& config)> CallbackType;
// DHCP and user-induced changes are on the order of seconds, so 150ms should // DHCP and user-induced changes are on the order of seconds, so 150ms should
// not add perceivable delay. On the other hand, config readers should finish // not add perceivable delay. On the other hand, config readers should finish
......
...@@ -61,8 +61,8 @@ class DnsConfigServiceTest : public TestWithTaskEnvironment { ...@@ -61,8 +61,8 @@ class DnsConfigServiceTest : public TestWithTaskEnvironment {
void SetUp() override { void SetUp() override {
service_.reset(new TestDnsConfigService()); service_.reset(new TestDnsConfigService());
service_->WatchConfig(base::Bind(&DnsConfigServiceTest::OnConfigChanged, service_->WatchConfig(base::BindRepeating(
base::Unretained(this))); &DnsConfigServiceTest::OnConfigChanged, base::Unretained(this)));
EXPECT_FALSE(last_config_.IsValid()); EXPECT_FALSE(last_config_.IsValid());
} }
......
...@@ -296,7 +296,7 @@ HostsParseWinResult AddLocalhostEntries(DnsHosts* hosts) { ...@@ -296,7 +296,7 @@ HostsParseWinResult AddLocalhostEntries(DnsHosts* hosts) {
// Watches a single registry key for changes. // Watches a single registry key for changes.
class RegistryWatcher { class RegistryWatcher {
public: public:
typedef base::Callback<void(bool succeeded)> CallbackType; typedef base::RepeatingCallback<void(bool succeeded)> CallbackType;
RegistryWatcher() {} RegistryWatcher() {}
~RegistryWatcher() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } ~RegistryWatcher() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); }
...@@ -607,9 +607,8 @@ class DnsConfigServiceWin::Watcher ...@@ -607,9 +607,8 @@ class DnsConfigServiceWin::Watcher
~Watcher() override { NetworkChangeNotifier::RemoveIPAddressObserver(this); } ~Watcher() override { NetworkChangeNotifier::RemoveIPAddressObserver(this); }
bool Watch() { bool Watch() {
RegistryWatcher::CallbackType callback = RegistryWatcher::CallbackType callback = base::BindRepeating(
base::Bind(&DnsConfigServiceWin::OnConfigChanged, &DnsConfigServiceWin::OnConfigChanged, base::Unretained(service_));
base::Unretained(service_));
bool success = true; bool success = true;
...@@ -635,8 +634,8 @@ class DnsConfigServiceWin::Watcher ...@@ -635,8 +634,8 @@ class DnsConfigServiceWin::Watcher
policy_watcher_.Watch(kPolicyPath, callback); policy_watcher_.Watch(kPolicyPath, callback);
if (!hosts_watcher_.Watch(GetHostsPath(), false, if (!hosts_watcher_.Watch(GetHostsPath(), false,
base::Bind(&Watcher::OnHostsChanged, base::BindRepeating(&Watcher::OnHostsChanged,
base::Unretained(this)))) { base::Unretained(this)))) {
UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus", UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus",
DNS_CONFIG_WATCH_FAILED_TO_START_HOSTS, DNS_CONFIG_WATCH_FAILED_TO_START_HOSTS,
DNS_CONFIG_WATCH_MAX); DNS_CONFIG_WATCH_MAX);
......
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