| 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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 if (num_active_requests() > 0) { | 1260 if (num_active_requests() > 0) { |
| 1261 UpdatePriority(); | 1261 UpdatePriority(); |
| 1262 } else { | 1262 } else { |
| 1263 // If we were called from a Request's callback within CompleteRequests, | 1263 // If we were called from a Request's callback within CompleteRequests, |
| 1264 // that Request could not have been cancelled, so num_active_requests() | 1264 // that Request could not have been cancelled, so num_active_requests() |
| 1265 // could not be 0. Therefore, we are not in CompleteRequests(). | 1265 // could not be 0. Therefore, we are not in CompleteRequests(). |
| 1266 CompleteRequestsWithError(OK /* cancelled */); | 1266 CompleteRequestsWithError(OK /* cancelled */); |
| 1267 } | 1267 } |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 // Called from AbortAllInProgressJobs. Completes all requests as aborted | 1270 // Called from AbortAllInProgressJobs. Completes all requests and destroys |
| 1271 // and destroys the job. | 1271 // the job. This currently assumes the abort is due to a network change. |
| 1272 void Abort() { | 1272 void Abort() { |
| 1273 DCHECK(is_running()); | 1273 DCHECK(is_running()); |
| 1274 CompleteRequestsWithError(ERR_ABORTED); | 1274 CompleteRequestsWithError(ERR_NETWORK_CHANGED); |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 // If DnsTask present, abort it and fall back to ProcTask. | 1277 // If DnsTask present, abort it and fall back to ProcTask. |
| 1278 void AbortDnsTask() { | 1278 void AbortDnsTask() { |
| 1279 if (dns_task_) { | 1279 if (dns_task_) { |
| 1280 dns_task_.reset(); | 1280 dns_task_.reset(); |
| 1281 dns_task_error_ = OK; | 1281 dns_task_error_ = OK; |
| 1282 StartProcTask(); | 1282 StartProcTask(); |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 | 1524 |
| 1525 DCHECK(!requests_.empty()); | 1525 DCHECK(!requests_.empty()); |
| 1526 | 1526 |
| 1527 if (entry.error == OK) { | 1527 if (entry.error == OK) { |
| 1528 // Record this histogram here, when we know the system has a valid DNS | 1528 // Record this histogram here, when we know the system has a valid DNS |
| 1529 // configuration. | 1529 // configuration. |
| 1530 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig", | 1530 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HaveDnsConfig", |
| 1531 resolver_->received_dns_config_); | 1531 resolver_->received_dns_config_); |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 bool did_complete = (entry.error != ERR_ABORTED) && | 1534 bool did_complete = (entry.error != ERR_NETWORK_CHANGED) && |
| 1535 (entry.error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); | 1535 (entry.error != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE); |
| 1536 if (did_complete) | 1536 if (did_complete) |
| 1537 resolver_->CacheResult(key_, entry, ttl); | 1537 resolver_->CacheResult(key_, entry, ttl); |
| 1538 | 1538 |
| 1539 // Complete all of the requests that were attached to the job. | 1539 // Complete all of the requests that were attached to the job. |
| 1540 for (RequestsList::const_iterator it = requests_.begin(); | 1540 for (RequestsList::const_iterator it = requests_.begin(); |
| 1541 it != requests_.end(); ++it) { | 1541 it != requests_.end(); ++it) { |
| 1542 Request* req = *it; | 1542 Request* req = *it; |
| 1543 | 1543 |
| 1544 if (req->was_canceled()) | 1544 if (req->was_canceled()) |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 } | 2165 } |
| 2166 DnsConfig dns_config; | 2166 DnsConfig dns_config; |
| 2167 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2167 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
| 2168 dns_client_->SetConfig(dns_config); | 2168 dns_client_->SetConfig(dns_config); |
| 2169 num_dns_failures_ = 0; | 2169 num_dns_failures_ = 0; |
| 2170 if (dns_config.IsValid()) | 2170 if (dns_config.IsValid()) |
| 2171 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2171 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
| 2172 } | 2172 } |
| 2173 | 2173 |
| 2174 } // namespace net | 2174 } // namespace net |
| OLD | NEW |