| 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_session.h" | 5 #include "net/dns/dns_session.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 initial_timeout_ = GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( | 127 initial_timeout_ = GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( |
| 128 "AsyncDnsInitialTimeoutMsByConnectionType", config_.timeout, type); | 128 "AsyncDnsInitialTimeoutMsByConnectionType", config_.timeout, type); |
| 129 max_timeout_ = GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( | 129 max_timeout_ = GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( |
| 130 "AsyncDnsMaxTimeoutMsByConnectionType", | 130 "AsyncDnsMaxTimeoutMsByConnectionType", |
| 131 base::TimeDelta::FromMilliseconds(kDefaultMaxTimeoutMs), type); | 131 base::TimeDelta::FromMilliseconds(kDefaultMaxTimeoutMs), type); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void DnsSession::InitializeServerStats() { | 134 void DnsSession::InitializeServerStats() { |
| 135 server_stats_.clear(); | 135 server_stats_.clear(); |
| 136 for (size_t i = 0; i < config_.nameservers.size(); ++i) { | 136 for (size_t i = 0; i < config_.nameservers.size(); ++i) { |
| 137 server_stats_.push_back(base::WrapUnique( | 137 server_stats_.push_back(base::MakeUnique<ServerStats>( |
| 138 new ServerStats(initial_timeout_, rtt_buckets_.Pointer()))); | 138 initial_timeout_, rtt_buckets_.Pointer())); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DnsSession::OnConnectionTypeChanged( | 142 void DnsSession::OnConnectionTypeChanged( |
| 143 NetworkChangeNotifier::ConnectionType type) { | 143 NetworkChangeNotifier::ConnectionType type) { |
| 144 UpdateTimeouts(type); | 144 UpdateTimeouts(type); |
| 145 const char* kTrialName = "AsyncDnsFlushServerStatsOnConnectionTypeChange"; | 145 const char* kTrialName = "AsyncDnsFlushServerStatsOnConnectionTypeChange"; |
| 146 if (base::FieldTrialList::FindFullName(kTrialName) == "enable") { | 146 if (base::FieldTrialList::FindFullName(kTrialName) == "enable") { |
| 147 RecordServerStats(); | 147 RecordServerStats(); |
| 148 InitializeServerStats(); | 148 InitializeServerStats(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); | 347 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); |
| 348 | 348 |
| 349 // The timeout still doubles every full round. | 349 // The timeout still doubles every full round. |
| 350 unsigned num_backoffs = attempt / config_.nameservers.size(); | 350 unsigned num_backoffs = attempt / config_.nameservers.size(); |
| 351 | 351 |
| 352 return std::min(timeout * (1 << num_backoffs), max_timeout_); | 352 return std::min(timeout * (1 << num_backoffs), max_timeout_); |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace net | 355 } // namespace net |
| OLD | NEW |