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.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 scoped_ptr<base::SampleVector> rtt_histogram; | 57 scoped_ptr<base::SampleVector> rtt_histogram; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(ServerStats); | 59 DISALLOW_COPY_AND_ASSIGN(ServerStats); |
60 }; | 60 }; |
61 | 61 |
62 // static | 62 // static |
63 base::LazyInstance<DnsSession::RttBuckets>::Leaky DnsSession::rtt_buckets_ = | 63 base::LazyInstance<DnsSession::RttBuckets>::Leaky DnsSession::rtt_buckets_ = |
64 LAZY_INSTANCE_INITIALIZER; | 64 LAZY_INSTANCE_INITIALIZER; |
65 | 65 |
66 DnsSession::RttBuckets::RttBuckets() : base::BucketRanges(kRTTBucketCount + 1) { | 66 DnsSession::RttBuckets::RttBuckets() : base::BucketRanges(kRTTBucketCount + 1) { |
67 base::Histogram::InitializeBucketRanges(1, 5000, kRTTBucketCount, this); | 67 base::Histogram::InitializeBucketRanges(1, 5000, this); |
68 } | 68 } |
69 | 69 |
70 DnsSession::SocketLease::SocketLease(scoped_refptr<DnsSession> session, | 70 DnsSession::SocketLease::SocketLease(scoped_refptr<DnsSession> session, |
71 unsigned server_index, | 71 unsigned server_index, |
72 scoped_ptr<DatagramClientSocket> socket) | 72 scoped_ptr<DatagramClientSocket> socket) |
73 : session_(session), server_index_(server_index), socket_(socket.Pass()) {} | 73 : session_(session), server_index_(server_index), socket_(socket.Pass()) {} |
74 | 74 |
75 DnsSession::SocketLease::~SocketLease() { | 75 DnsSession::SocketLease::~SocketLease() { |
76 session_->FreeSocket(server_index_, socket_.Pass()); | 76 session_->FreeSocket(server_index_, socket_.Pass()); |
77 } | 77 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); | 295 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); |
296 | 296 |
297 // The timeout still doubles every full round. | 297 // The timeout still doubles every full round. |
298 unsigned num_backoffs = attempt / config_.nameservers.size(); | 298 unsigned num_backoffs = attempt / config_.nameservers.size(); |
299 | 299 |
300 return std::min(timeout * (1 << num_backoffs), | 300 return std::min(timeout * (1 << num_backoffs), |
301 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); | 301 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); |
302 } | 302 } |
303 | 303 |
304 } // namespace net | 304 } // namespace net |
OLD | NEW |