OLD | NEW |
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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 AddressList(), | 1245 AddressList(), |
1246 base::TimeDelta()); | 1246 base::TimeDelta()); |
1247 } | 1247 } |
1248 | 1248 |
1249 // Attempts to serve the job from HOSTS. Returns true if succeeded and | 1249 // Attempts to serve the job from HOSTS. Returns true if succeeded and |
1250 // this Job was destroyed. | 1250 // this Job was destroyed. |
1251 bool ServeFromHosts() { | 1251 bool ServeFromHosts() { |
1252 DCHECK_GT(num_active_requests(), 0u); | 1252 DCHECK_GT(num_active_requests(), 0u); |
1253 AddressList addr_list; | 1253 AddressList addr_list; |
1254 if (resolver_->ServeFromHosts(key(), | 1254 if (resolver_->ServeFromHosts(key(), |
1255 requests_->front()->info(), | 1255 requests_.front()->info(), |
1256 &addr_list)) { | 1256 &addr_list)) { |
1257 // This will destroy the Job. | 1257 // This will destroy the Job. |
1258 CompleteRequests(OK, addr_list, base::TimeDelta()); | 1258 CompleteRequests(OK, addr_list, base::TimeDelta()); |
1259 return true; | 1259 return true; |
1260 } | 1260 } |
1261 return false; | 1261 return false; |
1262 } | 1262 } |
1263 | 1263 |
1264 const Key key() const { | 1264 const Key key() const { |
1265 return key_; | 1265 return key_; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 OK); | 1440 OK); |
1441 return; | 1441 return; |
1442 } | 1442 } |
1443 | 1443 |
1444 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, | 1444 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, |
1445 net_error); | 1445 net_error); |
1446 | 1446 |
1447 DCHECK(!requests_.empty()); | 1447 DCHECK(!requests_.empty()); |
1448 | 1448 |
1449 if (net_error == OK) { | 1449 if (net_error == OK) { |
1450 SetPortOnAddressList(requests_->front()->info().port(), &list); | 1450 SetPortOnAddressList(requests_.front()->info().port(), &list); |
1451 // Record this histogram here, when we know the system has a valid DNS | 1451 // Record this histogram here, when we know the system has a valid DNS |
1452 // configuration. | 1452 // configuration. |
1453 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig", | 1453 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig", |
1454 resolver_->received_dns_config_); | 1454 resolver_->received_dns_config_); |
1455 } | 1455 } |
1456 | 1456 |
1457 bool did_complete = (net_error != ERR_ABORTED) && | 1457 bool did_complete = (net_error != ERR_ABORTED) && |
1458 (net_error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); | 1458 (net_error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); |
1459 if (did_complete) | 1459 if (did_complete) |
1460 resolver_->CacheResult(key_, net_error, list, ttl); | 1460 resolver_->CacheResult(key_, net_error, list, ttl); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 if (self) | 2007 if (self) |
2008 TryServingAllJobsFromHosts(); | 2008 TryServingAllJobsFromHosts(); |
2009 } | 2009 } |
2010 } | 2010 } |
2011 | 2011 |
2012 bool HostResolverImpl::HaveDnsConfig() const { | 2012 bool HostResolverImpl::HaveDnsConfig() const { |
2013 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL); | 2013 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL); |
2014 } | 2014 } |
2015 | 2015 |
2016 } // namespace net | 2016 } // namespace net |
OLD | NEW |