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

Unified Diff: net/dns/dns_config_service.cc

Issue 10537106: [net/dns] Suppress multiple DnsConfig withdrawals after timeout. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added requested DCHECK. Created 8 years, 6 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
« no previous file with comments | « net/dns/dns_config_service.h ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bff1fc709f8df5d1b9f1e26f75dccf8e73b97573 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,10 @@ void DnsConfigService::OnHostsRead(const DnsHosts& hosts) {
void DnsConfigService::StartTimer() {
DCHECK(CalledOnValidThread());
+ if (last_sent_empty_) {
+ DCHECK(!timer_.IsRunning());
+ return; // No need to withdraw again.
+ }
timer_.Stop();
// Give it a short timeout to come up with a valid config. Otherwise withdraw
@@ -167,19 +172,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
« no previous file with comments | « net/dns/dns_config_service.h ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698