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

Unified Diff: net/dns/host_resolver_impl.cc

Issue 1047103002: Avoid initial NetworkChangeNotifier OnDNSChanged() signal on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert an accidental test enabling Created 5 years, 8 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/host_resolver_impl.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index f294b8c4bdffb0916ebd32ccc078dacac6bab828..35ea2fa29cb2e79977fcb2145f81633748b89d8d 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -2289,7 +2289,15 @@ void HostResolverImpl::OnIPAddressChanged() {
// |this| may be deleted inside AbortAllInProgressJobs().
}
+void HostResolverImpl::OnInitialDNSConfigRead() {
+ UpdateDNSConfig(false);
+}
+
void HostResolverImpl::OnDNSChanged() {
+ UpdateDNSConfig(true);
+}
+
+void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
DnsConfig dns_config;
NetworkChangeNotifier::GetDnsConfig(&dns_config);
@@ -2310,27 +2318,33 @@ void HostResolverImpl::OnDNSChanged() {
// the newly started jobs use the new config.
if (dns_client_.get()) {
dns_client_->SetConfig(dns_config);
- if (dns_client_->GetConfig())
+ if (dns_client_->GetConfig()) {
UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
+ // If we just switched DnsClients, restart jobs using new resolver.
+ // TODO(pauljensen): Is this necessary?
+ config_changed = true;
+ }
}
- // If the DNS server has changed, existing cached info could be wrong so we
- // have to drop our internal cache :( Note that OS level DNS caches, such
- // as NSCD's cache should be dropped automatically by the OS when
- // resolv.conf changes so we don't need to do anything to clear that cache.
- if (cache_.get())
- cache_->clear();
+ if (config_changed) {
+ // If the DNS server has changed, existing cached info could be wrong so we
+ // have to drop our internal cache :( Note that OS level DNS caches, such
+ // as NSCD's cache should be dropped automatically by the OS when
+ // resolv.conf changes so we don't need to do anything to clear that cache.
+ if (cache_.get())
+ cache_->clear();
- // Life check to bail once |this| is deleted.
- base::WeakPtr<HostResolverImpl> self = weak_ptr_factory_.GetWeakPtr();
+ // Life check to bail once |this| is deleted.
+ base::WeakPtr<HostResolverImpl> self = weak_ptr_factory_.GetWeakPtr();
- // Existing jobs will have been sent to the original server so they need to
- // be aborted.
- AbortAllInProgressJobs();
+ // Existing jobs will have been sent to the original server so they need to
+ // be aborted.
+ AbortAllInProgressJobs();
- // |this| may be deleted inside AbortAllInProgressJobs().
- if (self.get())
- TryServingAllJobsFromHosts();
+ // |this| may be deleted inside AbortAllInProgressJobs().
+ if (self.get())
+ TryServingAllJobsFromHosts();
+ }
}
bool HostResolverImpl::HaveDnsConfig() const {
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698