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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Number of buckets in the histogram of observed RTTs. | 30 // Number of buckets in the histogram of observed RTTs. |
31 const size_t kRTTBucketCount = 100; | 31 const size_t kRTTBucketCount = 100; |
32 // Target percentile in the RTT histogram used for retransmission timeout. | 32 // Target percentile in the RTT histogram used for retransmission timeout. |
33 const unsigned kRTOPercentile = 99; | 33 const unsigned kRTOPercentile = 99; |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 // Runtime statistics of DNS server. | 36 // Runtime statistics of DNS server. |
37 struct DnsSession::ServerStats { | 37 struct DnsSession::ServerStats { |
38 ServerStats(base::TimeDelta rtt_estimate_param, RttBuckets* buckets) | 38 ServerStats(base::TimeDelta rtt_estimate_param, RttBuckets* buckets) |
39 : last_failure_count(0), rtt_estimate(rtt_estimate_param) { | 39 : last_failure_count(0), rtt_estimate(rtt_estimate_param) { |
40 rtt_histogram.reset(new base::SampleVector(buckets)); | 40 rtt_histogram.reset(new base::SampleVector(0, buckets)); |
41 // Seed histogram with 2 samples at |rtt_estimate| timeout. | 41 // Seed histogram with 2 samples at |rtt_estimate| timeout. |
42 rtt_histogram->Accumulate( | 42 rtt_histogram->Accumulate( |
43 static_cast<base::HistogramBase::Sample>(rtt_estimate.InMilliseconds()), | 43 static_cast<base::HistogramBase::Sample>(rtt_estimate.InMilliseconds()), |
44 2); | 44 2); |
45 } | 45 } |
46 | 46 |
47 // Count of consecutive failures after last success. | 47 // Count of consecutive failures after last success. |
48 int last_failure_count; | 48 int last_failure_count; |
49 | 49 |
50 // Last time when server returned failure or timeout. | 50 // Last time when server returned failure or timeout. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); | 293 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); |
294 | 294 |
295 // The timeout still doubles every full round. | 295 // The timeout still doubles every full round. |
296 unsigned num_backoffs = attempt / config_.nameservers.size(); | 296 unsigned num_backoffs = attempt / config_.nameservers.size(); |
297 | 297 |
298 return std::min(timeout * (1 << num_backoffs), | 298 return std::min(timeout * (1 << num_backoffs), |
299 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); | 299 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); |
300 } | 300 } |
301 | 301 |
302 } // namespace net | 302 } // namespace net |
OLD | NEW |