Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: net/dns/dns_config_service.cc

Issue 10873018: [net] Move DnsConfigService to NetworkChangeNotifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Send DnsConfig() via OnTimeout after watch fails Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698