Commit 01b3b9d5 authored by szym@chromium.org's avatar szym@chromium.org

[net] Use only DnsConfigService to detect DNS changes in HostResolverImpl

The signals coming currently via DNSObserver are too noisy. DnsConfigService
can weed out false positives, so switch to using it exclusively.

BUG=142138
TEST=network requests work after network changes


Review URL: https://chromiumcodereview.appspot.com/10830271

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151278 0039d316-1c4b-4281-b951-d872f2087c98
parent 6e56662f
...@@ -1602,7 +1602,6 @@ HostResolverImpl::HostResolverImpl( ...@@ -1602,7 +1602,6 @@ HostResolverImpl::HostResolverImpl(
NetworkChangeNotifier::AddIPAddressObserver(this); NetworkChangeNotifier::AddIPAddressObserver(this);
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \ #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \
!defined(OS_ANDROID) !defined(OS_ANDROID)
NetworkChangeNotifier::AddDNSObserver(this);
EnsureDnsReloaderInit(); EnsureDnsReloaderInit();
#endif #endif
...@@ -1620,7 +1619,6 @@ HostResolverImpl::~HostResolverImpl() { ...@@ -1620,7 +1619,6 @@ HostResolverImpl::~HostResolverImpl() {
STLDeleteValues(&jobs_); STLDeleteValues(&jobs_);
NetworkChangeNotifier::RemoveIPAddressObserver(this); NetworkChangeNotifier::RemoveIPAddressObserver(this);
NetworkChangeNotifier::RemoveDNSObserver(this);
} }
void HostResolverImpl::SetMaxQueuedJobs(size_t value) { void HostResolverImpl::SetMaxQueuedJobs(size_t value) {
...@@ -1983,25 +1981,6 @@ void HostResolverImpl::OnIPAddressChanged() { ...@@ -1983,25 +1981,6 @@ void HostResolverImpl::OnIPAddressChanged() {
// |this| may be deleted inside AbortAllInProgressJobs(). // |this| may be deleted inside AbortAllInProgressJobs().
} }
void HostResolverImpl::OnDNSChanged(unsigned detail) {
// Ignore signals about watches.
const unsigned kIgnoredDetail =
NetworkChangeNotifier::CHANGE_DNS_WATCH_STARTED |
NetworkChangeNotifier::CHANGE_DNS_WATCH_FAILED;
if ((detail & ~kIgnoredDetail) == 0)
return;
// 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();
// Existing jobs will have been sent to the original server so they need to
// be aborted.
AbortAllInProgressJobs();
// |this| may be deleted inside AbortAllInProgressJobs().
}
void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) { void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) {
if (net_log_) { if (net_log_) {
net_log_->AddGlobalEntry( net_log_->AddGlobalEntry(
...@@ -2009,21 +1988,31 @@ void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) { ...@@ -2009,21 +1988,31 @@ void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) {
base::Bind(&NetLogDnsConfigCallback, &dns_config)); base::Bind(&NetLogDnsConfigCallback, &dns_config));
} }
// TODO(szym): Remove once http://crbug.com/125599 is resolved. // TODO(szym): Remove once http://crbug.com/137914 is resolved.
received_dns_config_ = dns_config.IsValid(); received_dns_config_ = dns_config.IsValid();
// Life check to bail once |this| is deleted. // Life check to bail once |this| is deleted.
base::WeakPtr<HostResolverImpl> self = AsWeakPtr(); base::WeakPtr<HostResolverImpl> self = AsWeakPtr();
if (dns_client_.get()) { // We want a new DnsSession in place, before we Abort running Jobs, so that
// We want a new factory in place, before we Abort running Jobs, so that the // the newly started jobs use the new config.
// newly started jobs use the new factory. if (dns_client_.get())
dns_client_->SetConfig(dns_config); dns_client_->SetConfig(dns_config);
OnDNSChanged(NetworkChangeNotifier::CHANGE_DNS_SETTINGS);
// |this| may be deleted inside OnDNSChanged(). // If the DNS server has changed, existing cached info could be wrong so we
if (self) // have to drop our internal cache :( Note that OS level DNS caches, such
TryServingAllJobsFromHosts(); // 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();
// 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)
TryServingAllJobsFromHosts();
} }
bool HostResolverImpl::HaveDnsConfig() const { bool HostResolverImpl::HaveDnsConfig() const {
......
...@@ -59,7 +59,6 @@ class NET_EXPORT HostResolverImpl ...@@ -59,7 +59,6 @@ class NET_EXPORT HostResolverImpl
: public HostResolver, : public HostResolver,
NON_EXPORTED_BASE(public base::NonThreadSafe), NON_EXPORTED_BASE(public base::NonThreadSafe),
public NetworkChangeNotifier::IPAddressObserver, public NetworkChangeNotifier::IPAddressObserver,
public NetworkChangeNotifier::DNSObserver,
public base::SupportsWeakPtr<HostResolverImpl> { public base::SupportsWeakPtr<HostResolverImpl> {
public: public:
// Parameters for ProcTask which resolves hostnames using HostResolveProc. // Parameters for ProcTask which resolves hostnames using HostResolveProc.
...@@ -219,9 +218,6 @@ class NET_EXPORT HostResolverImpl ...@@ -219,9 +218,6 @@ class NET_EXPORT HostResolverImpl
// NetworkChangeNotifier::IPAddressObserver: // NetworkChangeNotifier::IPAddressObserver:
virtual void OnIPAddressChanged() OVERRIDE; virtual void OnIPAddressChanged() OVERRIDE;
// NetworkChangeNotifier::DNSObserver:
virtual void OnDNSChanged(unsigned detail) OVERRIDE;
// DnsConfigService callback: // DnsConfigService callback:
void OnDnsConfigChanged(const DnsConfig& dns_config); void OnDnsConfigChanged(const DnsConfig& dns_config);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment