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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return std::min(timeout * (1 << num_backoffs), | 222 return std::min(timeout * (1 << num_backoffs), |
223 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); | 223 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); |
224 } | 224 } |
225 | 225 |
226 // Allocate a socket, already connected to the server address. | 226 // Allocate a socket, already connected to the server address. |
227 scoped_ptr<DnsSession::SocketLease> DnsSession::AllocateSocket( | 227 scoped_ptr<DnsSession::SocketLease> DnsSession::AllocateSocket( |
228 unsigned server_index, const NetLog::Source& source) { | 228 unsigned server_index, const NetLog::Source& source) { |
229 scoped_ptr<DatagramClientSocket> socket; | 229 scoped_ptr<DatagramClientSocket> socket; |
230 | 230 |
231 socket = socket_pool_->AllocateSocket(server_index); | 231 socket = socket_pool_->AllocateSocket(server_index); |
232 if (!socket.get()) return scoped_ptr<SocketLease>(NULL); | 232 if (!socket.get()) |
| 233 return scoped_ptr<SocketLease>(); |
233 | 234 |
234 socket->NetLog().BeginEvent(NetLog::TYPE_SOCKET_IN_USE, | 235 socket->NetLog().BeginEvent(NetLog::TYPE_SOCKET_IN_USE, |
235 source.ToEventParametersCallback()); | 236 source.ToEventParametersCallback()); |
236 | 237 |
237 SocketLease* lease = new SocketLease(this, server_index, socket.Pass()); | 238 SocketLease* lease = new SocketLease(this, server_index, socket.Pass()); |
238 return scoped_ptr<SocketLease>(lease); | 239 return scoped_ptr<SocketLease>(lease); |
239 } | 240 } |
240 | 241 |
241 scoped_ptr<StreamSocket> DnsSession::CreateTCPSocket( | 242 scoped_ptr<StreamSocket> DnsSession::CreateTCPSocket( |
242 unsigned server_index, const NetLog::Source& source) { | 243 unsigned server_index, const NetLog::Source& source) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); | 295 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); |
295 | 296 |
296 // The timeout still doubles every full round. | 297 // The timeout still doubles every full round. |
297 unsigned num_backoffs = attempt / config_.nameservers.size(); | 298 unsigned num_backoffs = attempt / config_.nameservers.size(); |
298 | 299 |
299 return std::min(timeout * (1 << num_backoffs), | 300 return std::min(timeout * (1 << num_backoffs), |
300 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); | 301 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); |
301 } | 302 } |
302 | 303 |
303 } // namespace net | 304 } // namespace net |
OLD | NEW |