| 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/dns_transaction.h" | 5 #include "net/dns/dns_transaction.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 // Makes another attempt at the current name, |qnames_.front()|, using the | 701 // Makes another attempt at the current name, |qnames_.front()|, using the |
| 702 // next nameserver. | 702 // next nameserver. |
| 703 AttemptResult MakeAttempt() { | 703 AttemptResult MakeAttempt() { |
| 704 unsigned attempt_number = attempts_.size(); | 704 unsigned attempt_number = attempts_.size(); |
| 705 | 705 |
| 706 uint16 id = session_->NextQueryId(); | 706 uint16 id = session_->NextQueryId(); |
| 707 scoped_ptr<DnsQuery> query; | 707 scoped_ptr<DnsQuery> query; |
| 708 if (attempts_.empty()) { | 708 if (attempts_.empty()) { |
| 709 query.reset(new DnsQuery(id, qnames_.front(), qtype_)); | 709 query.reset(new DnsQuery(id, qnames_.front(), qtype_)); |
| 710 } else { | 710 } else { |
| 711 query.reset(attempts_[0]->GetQuery()->CloneWithNewId(id)); | 711 query = attempts_[0]->GetQuery()->CloneWithNewId(id); |
| 712 } | 712 } |
| 713 | 713 |
| 714 const DnsConfig& config = session_->config(); | 714 const DnsConfig& config = session_->config(); |
| 715 | 715 |
| 716 unsigned server_index = | 716 unsigned server_index = |
| 717 (first_server_index_ + attempt_number) % config.nameservers.size(); | 717 (first_server_index_ + attempt_number) % config.nameservers.size(); |
| 718 // Skip over known failed servers. | 718 // Skip over known failed servers. |
| 719 server_index = session_->NextGoodServerIndex(server_index); | 719 server_index = session_->NextGoodServerIndex(server_index); |
| 720 | 720 |
| 721 scoped_ptr<DnsSession::SocketLease> lease = | 721 scoped_ptr<DnsSession::SocketLease> lease = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 752 DCHECK(previous_attempt); | 752 DCHECK(previous_attempt); |
| 753 DCHECK(!had_tcp_attempt_); | 753 DCHECK(!had_tcp_attempt_); |
| 754 | 754 |
| 755 unsigned server_index = previous_attempt->server_index(); | 755 unsigned server_index = previous_attempt->server_index(); |
| 756 | 756 |
| 757 scoped_ptr<StreamSocket> socket( | 757 scoped_ptr<StreamSocket> socket( |
| 758 session_->CreateTCPSocket(server_index, net_log_.source())); | 758 session_->CreateTCPSocket(server_index, net_log_.source())); |
| 759 | 759 |
| 760 // TODO(szym): Reuse the same id to help the server? | 760 // TODO(szym): Reuse the same id to help the server? |
| 761 uint16 id = session_->NextQueryId(); | 761 uint16 id = session_->NextQueryId(); |
| 762 scoped_ptr<DnsQuery> query( | 762 scoped_ptr<DnsQuery> query = |
| 763 previous_attempt->GetQuery()->CloneWithNewId(id)); | 763 previous_attempt->GetQuery()->CloneWithNewId(id); |
| 764 | 764 |
| 765 RecordLostPacketsIfAny(); | 765 RecordLostPacketsIfAny(); |
| 766 // Cancel all other attempts, no point waiting on them. | 766 // Cancel all other attempts, no point waiting on them. |
| 767 attempts_.clear(); | 767 attempts_.clear(); |
| 768 | 768 |
| 769 unsigned attempt_number = attempts_.size(); | 769 unsigned attempt_number = attempts_.size(); |
| 770 | 770 |
| 771 DnsTCPAttempt* attempt = new DnsTCPAttempt(server_index, socket.Pass(), | 771 DnsTCPAttempt* attempt = new DnsTCPAttempt(server_index, socket.Pass(), |
| 772 query.Pass()); | 772 query.Pass()); |
| 773 | 773 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 } // namespace | 992 } // namespace |
| 993 | 993 |
| 994 // static | 994 // static |
| 995 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( | 995 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( |
| 996 DnsSession* session) { | 996 DnsSession* session) { |
| 997 return scoped_ptr<DnsTransactionFactory>( | 997 return scoped_ptr<DnsTransactionFactory>( |
| 998 new DnsTransactionFactoryImpl(session)); | 998 new DnsTransactionFactoryImpl(session)); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 } // namespace net | 1001 } // namespace net |
| OLD | NEW |