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/dns/host_resolver_impl.h" | 5 #include "net/dns/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 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 } | 1417 } |
1418 } | 1418 } |
1419 | 1419 |
1420 AddressList MakeAddressListForRequest(const AddressList& list) const { | 1420 AddressList MakeAddressListForRequest(const AddressList& list) const { |
1421 if (requests_.empty()) | 1421 if (requests_.empty()) |
1422 return list; | 1422 return list; |
1423 return AddressList::CopyWithPort(list, requests_.front()->info().port()); | 1423 return AddressList::CopyWithPort(list, requests_.front()->info().port()); |
1424 } | 1424 } |
1425 | 1425 |
1426 // PriorityDispatch::Job: | 1426 // PriorityDispatch::Job: |
1427 virtual void Start() OVERRIDE { | 1427 virtual void Start() override { |
1428 DCHECK_LE(num_occupied_job_slots_, 1u); | 1428 DCHECK_LE(num_occupied_job_slots_, 1u); |
1429 | 1429 |
1430 handle_.Reset(); | 1430 handle_.Reset(); |
1431 ++num_occupied_job_slots_; | 1431 ++num_occupied_job_slots_; |
1432 | 1432 |
1433 if (num_occupied_job_slots_ == 2) { | 1433 if (num_occupied_job_slots_ == 2) { |
1434 StartSecondDnsTransaction(); | 1434 StartSecondDnsTransaction(); |
1435 return; | 1435 return; |
1436 } | 1436 } |
1437 | 1437 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 CompleteRequestsWithError(net_error); | 1583 CompleteRequestsWithError(net_error); |
1584 } | 1584 } |
1585 } | 1585 } |
1586 | 1586 |
1587 | 1587 |
1588 // HostResolverImpl::DnsTask::Delegate implementation: | 1588 // HostResolverImpl::DnsTask::Delegate implementation: |
1589 | 1589 |
1590 virtual void OnDnsTaskComplete(base::TimeTicks start_time, | 1590 virtual void OnDnsTaskComplete(base::TimeTicks start_time, |
1591 int net_error, | 1591 int net_error, |
1592 const AddressList& addr_list, | 1592 const AddressList& addr_list, |
1593 base::TimeDelta ttl) OVERRIDE { | 1593 base::TimeDelta ttl) override { |
1594 DCHECK(is_dns_running()); | 1594 DCHECK(is_dns_running()); |
1595 | 1595 |
1596 base::TimeDelta duration = base::TimeTicks::Now() - start_time; | 1596 base::TimeDelta duration = base::TimeTicks::Now() - start_time; |
1597 if (net_error != OK) { | 1597 if (net_error != OK) { |
1598 OnDnsTaskFailure(dns_task_->AsWeakPtr(), duration, net_error); | 1598 OnDnsTaskFailure(dns_task_->AsWeakPtr(), duration, net_error); |
1599 return; | 1599 return; |
1600 } | 1600 } |
1601 DNS_HISTOGRAM("AsyncDNS.ResolveSuccess", duration); | 1601 DNS_HISTOGRAM("AsyncDNS.ResolveSuccess", duration); |
1602 // Log DNS lookups based on |address_family|. | 1602 // Log DNS lookups based on |address_family|. |
1603 switch(key_.address_family) { | 1603 switch(key_.address_family) { |
(...skipping 14 matching lines...) Expand all Loading... |
1618 resolver_->OnDnsTaskResolve(OK); | 1618 resolver_->OnDnsTaskResolve(OK); |
1619 | 1619 |
1620 base::TimeDelta bounded_ttl = | 1620 base::TimeDelta bounded_ttl = |
1621 std::max(ttl, base::TimeDelta::FromSeconds(kMinimumTTLSeconds)); | 1621 std::max(ttl, base::TimeDelta::FromSeconds(kMinimumTTLSeconds)); |
1622 | 1622 |
1623 CompleteRequests( | 1623 CompleteRequests( |
1624 HostCache::Entry(net_error, MakeAddressListForRequest(addr_list), ttl), | 1624 HostCache::Entry(net_error, MakeAddressListForRequest(addr_list), ttl), |
1625 bounded_ttl); | 1625 bounded_ttl); |
1626 } | 1626 } |
1627 | 1627 |
1628 virtual void OnFirstDnsTransactionComplete() OVERRIDE { | 1628 virtual void OnFirstDnsTransactionComplete() override { |
1629 DCHECK(dns_task_->needs_two_transactions()); | 1629 DCHECK(dns_task_->needs_two_transactions()); |
1630 DCHECK_EQ(dns_task_->needs_another_transaction(), is_queued()); | 1630 DCHECK_EQ(dns_task_->needs_another_transaction(), is_queued()); |
1631 // No longer need to occupy two dispatcher slots. | 1631 // No longer need to occupy two dispatcher slots. |
1632 ReduceToOneJobSlot(); | 1632 ReduceToOneJobSlot(); |
1633 | 1633 |
1634 // We already have a job slot at the dispatcher, so if the second | 1634 // We already have a job slot at the dispatcher, so if the second |
1635 // transaction hasn't started, reuse it now instead of waiting in the queue | 1635 // transaction hasn't started, reuse it now instead of waiting in the queue |
1636 // for the second slot. | 1636 // for the second slot. |
1637 if (dns_task_->needs_another_transaction()) | 1637 if (dns_task_->needs_another_transaction()) |
1638 dns_task_->StartSecondTransaction(); | 1638 dns_task_->StartSecondTransaction(); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2359 dns_client_->SetConfig(dns_config); | 2359 dns_client_->SetConfig(dns_config); |
2360 num_dns_failures_ = 0; | 2360 num_dns_failures_ = 0; |
2361 if (dns_client_->GetConfig()) | 2361 if (dns_client_->GetConfig()) |
2362 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2362 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2363 } | 2363 } |
2364 | 2364 |
2365 AbortDnsTasks(); | 2365 AbortDnsTasks(); |
2366 } | 2366 } |
2367 | 2367 |
2368 } // namespace net | 2368 } // namespace net |
OLD | NEW |