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 2291b4ebb061d72fcc3b6021e92c9e5d20d3bfed..ff1bb1d4091f316a7bab138fcd7ebed8272a197f 100644 |
| --- a/net/dns/dns_config_service.cc |
| +++ b/net/dns/dns_config_service.cc |
| @@ -75,33 +75,30 @@ base::Value* DnsConfig::ToValue() const { |
| DnsConfigService::DnsConfigService() |
| - : have_config_(false), |
| + : watch_failed_(false), |
| + have_config_(false), |
| have_hosts_(false), |
| need_update_(false), |
| last_sent_empty_(true) {} |
| DnsConfigService::~DnsConfigService() { |
| - // Must always clean up. |
| - NetworkChangeNotifier::RemoveDNSObserver(this); |
| } |
| -void DnsConfigService::Read(const CallbackType& callback) { |
| +void DnsConfigService::ReadConfig(const CallbackType& callback) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(!callback.is_null()); |
| DCHECK(callback_.is_null()); |
| callback_ = callback; |
| - OnDNSChanged(NetworkChangeNotifier::CHANGE_DNS_WATCH_STARTED); |
| + ReadNow(); |
| } |
| -void DnsConfigService::Watch(const CallbackType& callback) { |
| +void DnsConfigService::WatchConfig(const CallbackType& callback) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(!callback.is_null()); |
| DCHECK(callback_.is_null()); |
| - NetworkChangeNotifier::AddDNSObserver(this); |
| callback_ = callback; |
| - if (NetworkChangeNotifier::IsWatchingDNS()) |
| - OnDNSChanged(NetworkChangeNotifier::CHANGE_DNS_WATCH_STARTED); |
| - // else: Wait until signal before reading. |
| + watch_failed_ = !StartWatching(); |
| + ReadNow(); |
| } |
| void DnsConfigService::InvalidateConfig() { |
| @@ -175,7 +172,7 @@ void DnsConfigService::OnHostsRead(const DnsHosts& hosts) { |
| void DnsConfigService::StartTimer() { |
| DCHECK(CalledOnValidThread()); |
| - if (last_sent_empty_) { |
| + if (last_sent_empty_ && !watch_failed_) { |
| DCHECK(!timer_.IsRunning()); |
| return; // No need to withdraw again. |
| } |
| @@ -200,7 +197,7 @@ void DnsConfigService::StartTimer() { |
| void DnsConfigService::OnTimeout() { |
| DCHECK(CalledOnValidThread()); |
| - DCHECK(!last_sent_empty_); |
| + DCHECK(!last_sent_empty_ || watch_failed_); |
| // 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; |
| @@ -211,6 +208,8 @@ void DnsConfigService::OnTimeout() { |
| } |
| void DnsConfigService::OnCompleteConfig() { |
| + if (watch_failed_) |
| + return; // Let it time out. |
|
mmenke
2012/08/31 15:05:59
Should we stop the timer if |needs_update_| is fal
szym
2012/08/31 15:55:57
I see. The idea is to not signal anything if we ha
mmenke
2012/08/31 16:04:03
I agree - think that this is the less confusing so
|
| timer_.Stop(); |
| if (!need_update_) |
| return; |