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..c06639dd3d2edc4de23afa157cc6f3173ba5ba92 100644 |
| --- a/net/dns/dns_session.h |
| +++ b/net/dns/dns_session.h |
| @@ -5,11 +5,16 @@ |
| #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/dns/dns_socket_pool.h" |
| +#include "net/udp/datagram_client_socket.h" |
| namespace net { |
| @@ -24,16 +29,31 @@ class NET_EXPORT_PRIVATE DnsSession |
| public: |
| typedef base::Callback<int()> RandCallback; |
| + class SocketLease { |
| + public: |
| + SocketLease(scoped_refptr<DnsSession> session, |
| + unsigned server_index, |
| + scoped_ptr<DatagramClientSocket> socket); |
| + ~SocketLease(); |
| + |
| + DatagramClientSocket* socket() { return socket_.get(); } |
| + |
| + private: |
| + scoped_refptr<DnsSession> session_; |
| + unsigned server_index_; |
| + scoped_ptr<DatagramClientSocket> socket_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SocketLease); |
| + }; |
| + |
| DnsSession(const DnsConfig& config, |
| - ClientSocketFactory* factory, |
| + scoped_ptr<DnsSocketPool> socket_pool, |
| const RandIntCallback& rand_int_callback, |
| 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,12 +63,19 @@ 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. |
|
szym
2012/09/26 11:16:12
Add remark here or above class SocketLease explain
Deprecated (see juliatuttle)
2012/09/26 20:44:50
Done.
|
| + scoped_ptr<SocketLease> AllocateSocket(unsigned server_index, |
| + const NetLog::Source& source); |
| + |
| private: |
| friend class base::RefCounted<DnsSession>; |
| - ~DnsSession(); |
| + |
| + // Release a socket. |
| + void FreeSocket(unsigned server_index, |
| + scoped_ptr<DatagramClientSocket> socket); |
| const DnsConfig config_; |
| - ClientSocketFactory* socket_factory_; |
| + scoped_ptr<DnsSocketPool> socket_pool_; |
| RandCallback rand_callback_; |
| NetLog* net_log_; |
| @@ -57,7 +84,6 @@ class NET_EXPORT_PRIVATE DnsSession |
| // 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); |
| }; |