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

Unified Diff: chrome/browser/net/dns_probe_job.cc

Issue 11530018: DnsProbeJob: Differentiate network and DNS errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename IsDnsServerError to DidReceiveDnsResponse Created 8 years 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 | « no previous file | chrome/browser/net/dns_probe_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/dns_probe_job.cc
diff --git a/chrome/browser/net/dns_probe_job.cc b/chrome/browser/net/dns_probe_job.cc
index d638d0c99772827eaac14ebe31a37a7883761c8e..dcd94d55ea61607afc4d300624cd3cc9958b0176 100644
--- a/chrome/browser/net/dns_probe_job.cc
+++ b/chrome/browser/net/dns_probe_job.cc
@@ -29,6 +29,22 @@ namespace chrome_browser_net {
namespace {
+// Returns true if the given net_error indicates that we received a response
+// from the DNS server containing an error, or false if the given net_error
+// indicates that we never received a response.
+bool DidReceiveDnsResponse(int net_error) {
+ switch (net_error) {
+ case net::ERR_NAME_NOT_RESOLVED: // NXDOMAIN maps to this.
+ case net::ERR_DNS_MALFORMED_RESPONSE:
+ case net::ERR_DNS_SERVER_REQUIRES_TCP:
+ case net::ERR_DNS_SERVER_FAILED:
+ case net::ERR_DNS_SORT_ERROR: // Can only happen if the server responds.
+ return true;
+ default:
+ return false;
+ }
+}
+
class DnsProbeJobImpl : public DnsProbeJob {
public:
DnsProbeJobImpl(scoped_ptr<DnsClient> dns_client,
@@ -139,7 +155,7 @@ DnsProbeJobImpl::QueryResult DnsProbeJobImpl::EvaluateGoodResponse(
int net_error,
const DnsResponse* response) {
if (net_error != net::OK)
- return QUERY_NET_ERROR;
+ return DidReceiveDnsResponse(net_error) ? QUERY_DNS_ERROR : QUERY_NET_ERROR;
AddressList addr_list;
TimeDelta ttl;
@@ -160,10 +176,8 @@ DnsProbeJobImpl::QueryResult DnsProbeJobImpl::EvaluateBadResponse(
if (net_error == net::ERR_NAME_NOT_RESOLVED) // NXDOMAIN maps to this
return QUERY_CORRECT;
- // TODO(ttuttle): Examine net_error a little more closely to see whether
- // it's a DNS error or a network error.
if (net_error != net::OK)
- return QUERY_NET_ERROR;
+ return DidReceiveDnsResponse(net_error) ? QUERY_DNS_ERROR : QUERY_NET_ERROR;
return QUERY_INCORRECT;
}
« no previous file with comments | « no previous file | chrome/browser/net/dns_probe_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698