| 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_SOCKET_POOL_H_ | 5 #ifndef NET_DNS_DNS_SOCKET_POOL_H_ |
| 6 #define NET_DNS_DNS_SOCKET_POOL_H_ | 6 #define NET_DNS_DNS_SOCKET_POOL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/base/rand_callback.h" | 13 #include "net/base/rand_callback.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class ClientSocketFactory; | 17 class ClientSocketFactory; |
| 18 class DatagramClientSocket; | 18 class DatagramClientSocket; |
| 19 class IPEndPoint; | 19 class IPEndPoint; |
| 20 class NetLog; | 20 class NetLog; |
| 21 struct NetLogSource; | 21 struct NetLogSource; |
| 22 class StreamSocket; | 22 class StreamSocket; |
| 23 | 23 |
| 24 // A DnsSocketPool is an abstraction layer around a ClientSocketFactory that | 24 // A DnsSocketPool is an abstraction layer around a ClientSocketFactory that |
| 25 // allows preallocation, reuse, or other strategies to manage sockets connected | 25 // allows preallocation, reuse, or other strategies to manage sockets connected |
| 26 // to DNS servers. | 26 // to DNS servers. |
| 27 class NET_EXPORT_PRIVATE DnsSocketPool { | 27 class NET_EXPORT_PRIVATE DnsSocketPool { |
| 28 public: | 28 public: |
| 29 virtual ~DnsSocketPool() { } | 29 virtual ~DnsSocketPool(); |
| 30 | 30 |
| 31 // Creates a DnsSocketPool that implements the default strategy for managing | 31 // Creates a DnsSocketPool that implements the default strategy for managing |
| 32 // sockets. (This varies by platform; see DnsSocketPoolImpl in | 32 // sockets. (This varies by platform; see DnsSocketPoolImpl in |
| 33 // dns_socket_pool.cc for details.) | 33 // dns_socket_pool.cc for details.) |
| 34 static std::unique_ptr<DnsSocketPool> CreateDefault( | 34 static std::unique_ptr<DnsSocketPool> CreateDefault( |
| 35 ClientSocketFactory* factory, | 35 ClientSocketFactory* factory, |
| 36 const RandIntCallback& rand_int_callback); | 36 const RandIntCallback& rand_int_callback); |
| 37 | 37 |
| 38 // Creates a DnsSocketPool that implements a "null" strategy -- no sockets are | 38 // Creates a DnsSocketPool that implements a "null" strategy -- no sockets are |
| 39 // preallocated, allocation requests are satisfied by calling the factory | 39 // preallocated, allocation requests are satisfied by calling the factory |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 NetLog* net_log); | 78 NetLog* net_log); |
| 79 | 79 |
| 80 std::unique_ptr<DatagramClientSocket> CreateConnectedSocket( | 80 std::unique_ptr<DatagramClientSocket> CreateConnectedSocket( |
| 81 unsigned server_index); | 81 unsigned server_index); |
| 82 | 82 |
| 83 // Returns a random int in the specified range. | 83 // Returns a random int in the specified range. |
| 84 int GetRandomInt(int min, int max); | 84 int GetRandomInt(int min, int max); |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 ClientSocketFactory* socket_factory_; | 87 ClientSocketFactory* socket_factory_; |
| 88 const RandIntCallback& rand_int_callback_; | 88 const RandIntCallback rand_int_callback_; |
| 89 NetLog* net_log_; | 89 NetLog* net_log_; |
| 90 const std::vector<IPEndPoint>* nameservers_; | 90 const std::vector<IPEndPoint>* nameservers_; |
| 91 bool initialized_; | 91 bool initialized_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(DnsSocketPool); | 93 DISALLOW_COPY_AND_ASSIGN(DnsSocketPool); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace net | 96 } // namespace net |
| 97 | 97 |
| 98 #endif // NET_DNS_DNS_SOCKET_POOL_H_ | 98 #endif // NET_DNS_DNS_SOCKET_POOL_H_ |
| OLD | NEW |