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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/metrics/sample_vector.h" | 18 #include "base/metrics/sample_vector.h" |
19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/values.h" |
22 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
24 #include "net/dns/dns_config_service.h" | 25 #include "net/dns/dns_config_service.h" |
25 #include "net/dns/dns_socket_pool.h" | 26 #include "net/dns/dns_socket_pool.h" |
26 #include "net/dns/dns_util.h" | 27 #include "net/dns/dns_util.h" |
27 #include "net/socket/stream_socket.h" | 28 #include "net/socket/stream_socket.h" |
28 #include "net/udp/datagram_client_socket.h" | 29 #include "net/udp/datagram_client_socket.h" |
29 | 30 |
30 namespace net { | 31 namespace net { |
31 | 32 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 SocketLease* lease = new SocketLease(this, server_index, std::move(socket)); | 283 SocketLease* lease = new SocketLease(this, server_index, std::move(socket)); |
283 return std::unique_ptr<SocketLease>(lease); | 284 return std::unique_ptr<SocketLease>(lease); |
284 } | 285 } |
285 | 286 |
286 std::unique_ptr<StreamSocket> DnsSession::CreateTCPSocket( | 287 std::unique_ptr<StreamSocket> DnsSession::CreateTCPSocket( |
287 unsigned server_index, | 288 unsigned server_index, |
288 const NetLog::Source& source) { | 289 const NetLog::Source& source) { |
289 return socket_pool_->CreateTCPSocket(server_index, source); | 290 return socket_pool_->CreateTCPSocket(server_index, source); |
290 } | 291 } |
291 | 292 |
| 293 void DnsSession::ApplyPersistentData(const base::Value& data) {} |
| 294 |
| 295 std::unique_ptr<const base::Value> DnsSession::GetPersistentData() const { |
| 296 return std::unique_ptr<const base::Value>(); |
| 297 } |
| 298 |
292 // Release a socket. | 299 // Release a socket. |
293 void DnsSession::FreeSocket(unsigned server_index, | 300 void DnsSession::FreeSocket(unsigned server_index, |
294 std::unique_ptr<DatagramClientSocket> socket) { | 301 std::unique_ptr<DatagramClientSocket> socket) { |
295 DCHECK(socket.get()); | 302 DCHECK(socket.get()); |
296 | 303 |
297 socket->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE); | 304 socket->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE); |
298 | 305 |
299 socket_pool_->FreeSocket(server_index, std::move(socket)); | 306 socket_pool_->FreeSocket(server_index, std::move(socket)); |
300 } | 307 } |
301 | 308 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 345 |
339 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); | 346 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); |
340 | 347 |
341 // The timeout still doubles every full round. | 348 // The timeout still doubles every full round. |
342 unsigned num_backoffs = attempt / config_.nameservers.size(); | 349 unsigned num_backoffs = attempt / config_.nameservers.size(); |
343 | 350 |
344 return std::min(timeout * (1 << num_backoffs), max_timeout_); | 351 return std::min(timeout * (1 << num_backoffs), max_timeout_); |
345 } | 352 } |
346 | 353 |
347 } // namespace net | 354 } // namespace net |
OLD | NEW |