Chromium Code Reviews| Index: net/dns/dns_session.h |
| diff --git a/net/dns/dns_session.h b/net/dns/dns_session.h |
| index 70728c7837b8558493776d0dc46a5d398c7bce8e..a0d5dc59dbb08a9960dbf69d40f74e2c32f80789 100644 |
| --- a/net/dns/dns_session.h |
| +++ b/net/dns/dns_session.h |
| @@ -5,11 +5,15 @@ |
| #ifndef NET_DNS_DNS_SESSION_H_ |
| #define NET_DNS_DNS_SESSION_H_ |
| +#include <vector> |
| + |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/time.h" |
| #include "net/base/net_export.h" |
| #include "net/base/rand_callback.h" |
| #include "net/dns/dns_config_service.h" |
| +#include "net/udp/datagram_client_socket.h" |
| namespace net { |
| @@ -24,16 +28,30 @@ class NET_EXPORT_PRIVATE DnsSession |
| public: |
| typedef base::Callback<int()> RandCallback; |
| + class SocketLease { |
| + public: |
| + SocketLease(scoped_refptr<DnsSession> session, |
| + int server_index, |
| + scoped_ptr<DatagramClientSocket> socket); |
| + ~SocketLease(); |
| + |
| + DatagramClientSocket* socket() { return socket_.get(); } |
| + |
| + private: |
| + scoped_refptr<DnsSession> session_; |
| + int server_index_; |
| + scoped_ptr<DatagramClientSocket> socket_; |
| + }; |
| + |
| DnsSession(const DnsConfig& config, |
| ClientSocketFactory* factory, |
| const RandIntCallback& rand_int_callback, |
| + bool bypass_pools, |
|
szym
2012/09/04 15:42:27
You could also consider making SocketPool a separa
|
| NetLog* net_log); |
| const DnsConfig& config() const { return config_; } |
| NetLog* net_log() const { return net_log_; } |
| - ClientSocketFactory* socket_factory() { return socket_factory_; } |
| - |
| // Return the next random query ID. |
| int NextQueryId() const; |
| @@ -43,21 +61,31 @@ class NET_EXPORT_PRIVATE DnsSession |
| // Return the timeout for the next query. |
| base::TimeDelta NextTimeout(int attempt); |
| + // Allocate a socket, already connected to the server address. |
| + // TODO(szym): add NetLog param? |
| + scoped_ptr<SocketLease> AllocateSocket(int server_index); |
|
cbentzel
2012/08/29 16:48:06
Not sure that I like using a server_index for this
szym
2012/08/29 16:57:08
If it's an IPEndPoint, this will have to keep a ma
cbentzel
2012/08/29 17:03:48
OK, int may be fine. But would we want to be able
Deprecated (see juliatuttle)
2012/08/29 17:52:34
I don't think DnsConfig changes are that common th
|
| + |
| private: |
| friend class base::RefCounted<DnsSession>; |
| + |
| ~DnsSession(); |
| + // Release a socket. |
| + void FreeSocket(int server_index, scoped_ptr<DatagramClientSocket> socket); |
| + |
| const DnsConfig config_; |
| ClientSocketFactory* socket_factory_; |
| RandCallback rand_callback_; |
| + bool bypass_pools_; |
| NetLog* net_log_; |
| + std::vector<std::vector<DatagramClientSocket*> > pools_; |
| + |
| // Current index into |config_.nameservers| to begin resolution with. |
| int server_index_; |
| // TODO(szym): Add current RTT estimate. |
| // TODO(szym): Add TCP connection pool to support DNS over TCP. |
| - // TODO(szym): Add UDP port pool to avoid NAT table overload. |
| DISALLOW_COPY_AND_ASSIGN(DnsSession); |
| }; |