Chromium Code Reviews| Index: net/dns/dns_config_service.cc |
| diff --git a/net/dns/dns_config_service.cc b/net/dns/dns_config_service.cc |
| index d189def3c1f19e3f5b66dc36a2a344102922d96f..198af8f9f867cba0a8c3d667d8d3e60918bba799 100644 |
| --- a/net/dns/dns_config_service.cc |
| +++ b/net/dns/dns_config_service.cc |
| @@ -75,7 +75,8 @@ base::Value* DnsConfig::ToValue() const { |
| DnsConfigService::DnsConfigService() |
| : have_config_(false), |
| have_hosts_(false), |
| - need_update_(false) {} |
| + need_update_(false), |
| + last_sent_empty_(true) {} |
| DnsConfigService::~DnsConfigService() { |
| // Must always clean up. |
| @@ -146,6 +147,8 @@ void DnsConfigService::OnHostsRead(const DnsHosts& hosts) { |
| void DnsConfigService::StartTimer() { |
| DCHECK(CalledOnValidThread()); |
| + if (last_sent_empty_) |
| + return; // No need to withdraw again. |
|
mmenke
2012/06/11 22:46:25
optional: May also want to DHCECK that the timer
|
| timer_.Stop(); |
| // Give it a short timeout to come up with a valid config. Otherwise withdraw |
| @@ -167,19 +170,22 @@ void DnsConfigService::StartTimer() { |
| void DnsConfigService::OnTimeout() { |
| DCHECK(CalledOnValidThread()); |
| + DCHECK(!last_sent_empty_); |
| // Indicate that even if there is no change in On*Read, we will need to |
| // update the receiver when the config becomes complete. |
| need_update_ = true; |
| // Empty config is considered invalid. |
| + last_sent_empty_ = true; |
| callback_.Run(DnsConfig()); |
| } |
| void DnsConfigService::OnCompleteConfig() { |
| timer_.Stop(); |
| - if (need_update_) { |
| - need_update_ = false; |
| - callback_.Run(dns_config_); |
| - } |
| + if (!need_update_) |
| + return; |
| + need_update_ = false; |
| + last_sent_empty_ = false; |
| + callback_.Run(dns_config_); |
| } |
| } // namespace net |