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

Side by Side Diff: net/base/host_resolver_impl.cc

Issue 10479005: [net/dns] Only record HaveDnsChanged if the nameserver is not INADDR_ANY. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add bug number. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 1426
1427 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, 1427 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
1428 net_error); 1428 net_error);
1429 1429
1430 DCHECK(!requests_.empty()); 1430 DCHECK(!requests_.empty());
1431 1431
1432 if (net_error == OK) { 1432 if (net_error == OK) {
1433 SetPortOnAddressList(requests_->front()->info().port(), &list); 1433 SetPortOnAddressList(requests_->front()->info().port(), &list);
1434 // Record this histogram here, when we know the system has a valid DNS 1434 // Record this histogram here, when we know the system has a valid DNS
1435 // configuration. 1435 // configuration.
1436 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.HaveDnsConfig", 1436 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig",
1437 resolver_->received_dns_config_ ? 1 : 0, 1437 resolver_->received_dns_config_);
1438 2);
1439 } 1438 }
1440 1439
1441 if ((net_error != ERR_ABORTED) && 1440 if ((net_error != ERR_ABORTED) &&
1442 (net_error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)) { 1441 (net_error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)) {
1443 resolver_->CacheResult(key_, net_error, list, ttl); 1442 resolver_->CacheResult(key_, net_error, list, ttl);
1444 } 1443 }
1445 1444
1446 // Complete all of the requests that were attached to the job. 1445 // Complete all of the requests that were attached to the job.
1447 for (RequestsList::const_iterator it = requests_.begin(); 1446 for (RequestsList::const_iterator it = requests_.begin();
1448 it != requests_.end(); ++it) { 1447 it != requests_.end(); ++it) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 } 1958 }
1960 1959
1961 void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) { 1960 void HostResolverImpl::OnDnsConfigChanged(const DnsConfig& dns_config) {
1962 if (net_log_) { 1961 if (net_log_) {
1963 net_log_->AddGlobalEntry( 1962 net_log_->AddGlobalEntry(
1964 NetLog::TYPE_DNS_CONFIG_CHANGED, 1963 NetLog::TYPE_DNS_CONFIG_CHANGED,
1965 make_scoped_refptr(new DnsConfigParameters(dns_config))); 1964 make_scoped_refptr(new DnsConfigParameters(dns_config)));
1966 } 1965 }
1967 1966
1968 // TODO(szym): Remove once http://crbug.com/125599 is resolved. 1967 // TODO(szym): Remove once http://crbug.com/125599 is resolved.
1969 received_dns_config_ = dns_config.IsValid(); 1968 received_dns_config_ = false;
1969 if (dns_config.IsValid()) {
1970 // Quick check if the address is not INADDR_ANY, which is the default value
1971 // in absence of network connection. http://crbug.com/130808
1972 if (dns_config.nameservers[0].address()[0]) {
mmenke 2012/06/01 22:20:27 Is it possible that we'd have INADDR_ANY, followed
1973 received_dns_config_ = true;
1974 }
mmenke 2012/06/01 22:20:27 nit: No brackets for single-line ifs.
mmenke 2012/06/01 22:21:20 Actually, I'm never sure if that is optional or no
mmenke 2012/06/01 22:24:14 Ahh, chromium style guide: Other formatting "rule
1975 }
1970 1976
1971 // Life check to bail once |this| is deleted. 1977 // Life check to bail once |this| is deleted.
1972 base::WeakPtr<HostResolverImpl> self = AsWeakPtr(); 1978 base::WeakPtr<HostResolverImpl> self = AsWeakPtr();
1973 1979
1974 if (dns_client_.get()) { 1980 if (dns_client_.get()) {
1975 // We want a new factory in place, before we Abort running Jobs, so that the 1981 // We want a new factory in place, before we Abort running Jobs, so that the
1976 // newly started jobs use the new factory. 1982 // newly started jobs use the new factory.
1977 dns_client_->SetConfig(dns_config); 1983 dns_client_->SetConfig(dns_config);
1978 OnDNSChanged(NetworkChangeNotifier::CHANGE_DNS_SETTINGS); 1984 OnDNSChanged(NetworkChangeNotifier::CHANGE_DNS_SETTINGS);
1979 // |this| may be deleted inside OnDNSChanged(). 1985 // |this| may be deleted inside OnDNSChanged().
1980 if (self) 1986 if (self)
1981 TryServingAllJobsFromHosts(); 1987 TryServingAllJobsFromHosts();
1982 } 1988 }
1983 } 1989 }
1984 1990
1985 bool HostResolverImpl::HaveDnsConfig() const { 1991 bool HostResolverImpl::HaveDnsConfig() const {
1986 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL); 1992 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL);
1987 } 1993 }
1988 1994
1989 } // namespace net 1995 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698