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 #ifndef NET_DNS_DNS_SESSION_H_ | 5 #ifndef NET_DNS_DNS_SESSION_H_ |
6 #define NET_DNS_DNS_SESSION_H_ | 6 #define NET_DNS_DNS_SESSION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 typedef base::Callback<int()> RandCallback; | 27 typedef base::Callback<int()> RandCallback; |
28 | 28 |
29 DnsSession(const DnsConfig& config, | 29 DnsSession(const DnsConfig& config, |
30 ClientSocketFactory* factory, | 30 ClientSocketFactory* factory, |
31 const RandIntCallback& rand_int_callback, | 31 const RandIntCallback& rand_int_callback, |
32 NetLog* net_log); | 32 NetLog* net_log); |
33 | 33 |
34 const DnsConfig& config() const { return config_; } | 34 const DnsConfig& config() const { return config_; } |
35 NetLog* net_log() const { return net_log_; } | 35 NetLog* net_log() const { return net_log_; } |
36 | 36 |
37 ClientSocketFactory* socket_factory() { return socket_factory_.get(); } | 37 ClientSocketFactory* socket_factory() { return socket_factory_; } |
38 | 38 |
39 // Return the next random query ID. | 39 // Return the next random query ID. |
40 int NextQueryId() const; | 40 int NextQueryId() const; |
41 | 41 |
42 // Return the index of the first configured server to use on first attempt. | 42 // Return the index of the first configured server to use on first attempt. |
43 int NextFirstServerIndex(); | 43 int NextFirstServerIndex(); |
44 | 44 |
45 // Return the timeout for the next query. | 45 // Return the timeout for the next query. |
46 base::TimeDelta NextTimeout(int attempt); | 46 base::TimeDelta NextTimeout(int attempt); |
47 | 47 |
48 private: | 48 private: |
49 friend class base::RefCounted<DnsSession>; | 49 friend class base::RefCounted<DnsSession>; |
50 ~DnsSession(); | 50 ~DnsSession(); |
51 | 51 |
52 const DnsConfig config_; | 52 const DnsConfig config_; |
53 scoped_ptr<ClientSocketFactory> socket_factory_; | 53 ClientSocketFactory* socket_factory_; |
54 RandCallback rand_callback_; | 54 RandCallback rand_callback_; |
55 NetLog* net_log_; | 55 NetLog* net_log_; |
56 | 56 |
57 // Current index into |config_.nameservers| to begin resolution with. | 57 // Current index into |config_.nameservers| to begin resolution with. |
58 int server_index_; | 58 int server_index_; |
59 | 59 |
60 // TODO(szym): Add current RTT estimate. | 60 // TODO(szym): Add current RTT estimate. |
61 // TODO(szym): Add TCP connection pool to support DNS over TCP. | 61 // TODO(szym): Add TCP connection pool to support DNS over TCP. |
62 // TODO(szym): Add UDP port pool to avoid NAT table overload. | 62 // TODO(szym): Add UDP port pool to avoid NAT table overload. |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(DnsSession); | 64 DISALLOW_COPY_AND_ASSIGN(DnsSession); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace net | 67 } // namespace net |
68 | 68 |
69 #endif // NET_DNS_DNS_SESSION_H_ | 69 #endif // NET_DNS_DNS_SESSION_H_ |
70 | 70 |
OLD | NEW |