| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 for (first_completed = 0; first_completed < attempts_.size(); | 795 for (first_completed = 0; first_completed < attempts_.size(); |
| 796 ++first_completed) { | 796 ++first_completed) { |
| 797 if (attempts_[first_completed]->is_completed()) | 797 if (attempts_[first_completed]->is_completed()) |
| 798 break; | 798 break; |
| 799 } | 799 } |
| 800 // If there were no completed attempts, then we must be offline, so don't | 800 // If there were no completed attempts, then we must be offline, so don't |
| 801 // record any attempts as lost packets. | 801 // record any attempts as lost packets. |
| 802 if (first_completed == attempts_.size()) | 802 if (first_completed == attempts_.size()) |
| 803 return; | 803 return; |
| 804 | 804 |
| 805 std::vector<int> num_rounds(session_->config().nameservers.size()); | 805 size_t num_servers = session_->config().nameservers.size(); |
| 806 for (size_t i = 0; i < first_completed; ++i) { | 806 for (size_t i = 0; i < first_completed; ++i) { |
| 807 unsigned server_index = attempts_[i]->GetServerIndex(); | |
| 808 int server_round = num_rounds[server_index]++; | |
| 809 // Don't record lost packet unless attempt is in pending state. | 807 // Don't record lost packet unless attempt is in pending state. |
| 810 if (!attempts_[i]->is_pending()) | 808 if (!attempts_[i]->is_pending()) |
| 811 continue; | 809 continue; |
| 812 session_->RecordLostPacket(server_index, server_round); | 810 unsigned server_index = attempts_[i]->GetServerIndex(); |
| 811 // Servers are rotated in round robin, so server round can be calculated |
| 812 // from attempt index. |
| 813 size_t server_round = i / num_servers; |
| 814 session_->RecordLostPacket(server_index, static_cast<int>(server_round)); |
| 813 } | 815 } |
| 814 } | 816 } |
| 815 | 817 |
| 816 void LogResponse(const DnsAttempt* attempt) { | 818 void LogResponse(const DnsAttempt* attempt) { |
| 817 if (attempt && attempt->GetResponse()) { | 819 if (attempt && attempt->GetResponse()) { |
| 818 net_log_.AddEvent( | 820 net_log_.AddEvent( |
| 819 NetLog::TYPE_DNS_TRANSACTION_RESPONSE, | 821 NetLog::TYPE_DNS_TRANSACTION_RESPONSE, |
| 820 base::Bind(&DnsAttempt::NetLogResponseCallback, | 822 base::Bind(&DnsAttempt::NetLogResponseCallback, |
| 821 base::Unretained(attempt))); | 823 base::Unretained(attempt))); |
| 822 } | 824 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 } // namespace | 951 } // namespace |
| 950 | 952 |
| 951 // static | 953 // static |
| 952 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( | 954 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( |
| 953 DnsSession* session) { | 955 DnsSession* session) { |
| 954 return scoped_ptr<DnsTransactionFactory>( | 956 return scoped_ptr<DnsTransactionFactory>( |
| 955 new DnsTransactionFactoryImpl(session)); | 957 new DnsTransactionFactoryImpl(session)); |
| 956 } | 958 } |
| 957 | 959 |
| 958 } // namespace net | 960 } // namespace net |
| OLD | NEW |