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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/base/net_log.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 class ClientSocketFactory; | 16 class ClientSocketFactory; |
16 class DatagramClientSocket; | 17 class DatagramClientSocket; |
17 class IPEndPoint; | 18 class IPEndPoint; |
18 class NetLog; | 19 class NetLog; |
| 20 class StreamSocket; |
19 | 21 |
20 // A DnsSocketPool is an abstraction layer around a ClientSocketFactory that | 22 // A DnsSocketPool is an abstraction layer around a ClientSocketFactory that |
21 // allows preallocation, reuse, or other strategies to manage sockets connected | 23 // allows preallocation, reuse, or other strategies to manage sockets connected |
22 // to DNS servers. | 24 // to DNS servers. |
23 class NET_EXPORT_PRIVATE DnsSocketPool { | 25 class NET_EXPORT_PRIVATE DnsSocketPool { |
24 public: | 26 public: |
25 virtual ~DnsSocketPool() { } | 27 virtual ~DnsSocketPool() { } |
26 | 28 |
27 // Creates a DnsSocketPool that implements the default strategy for managing | 29 // Creates a DnsSocketPool that implements the default strategy for managing |
28 // sockets. (This varies by platform; see DnsSocketPoolImpl in | 30 // sockets. (This varies by platform; see DnsSocketPoolImpl in |
(...skipping 23 matching lines...) Expand all Loading... |
52 // one on which Connect fails). | 54 // one on which Connect fails). |
53 virtual scoped_ptr<DatagramClientSocket> AllocateSocket( | 55 virtual scoped_ptr<DatagramClientSocket> AllocateSocket( |
54 unsigned server_index) = 0; | 56 unsigned server_index) = 0; |
55 | 57 |
56 // Frees a socket allocated by AllocateSocket. |server_index| must be the | 58 // Frees a socket allocated by AllocateSocket. |server_index| must be the |
57 // same index passed to AllocateSocket. | 59 // same index passed to AllocateSocket. |
58 virtual void FreeSocket( | 60 virtual void FreeSocket( |
59 unsigned server_index, | 61 unsigned server_index, |
60 scoped_ptr<DatagramClientSocket> socket) = 0; | 62 scoped_ptr<DatagramClientSocket> socket) = 0; |
61 | 63 |
| 64 // Creates a StreamSocket from the factory for a transaction over TCP. These |
| 65 // sockets are not pooled. |
| 66 scoped_ptr<StreamSocket> CreateTCPSocket( |
| 67 unsigned server_index, |
| 68 const NetLog::Source& source); |
| 69 |
62 protected: | 70 protected: |
63 DnsSocketPool(ClientSocketFactory* socket_factory); | 71 DnsSocketPool(ClientSocketFactory* socket_factory); |
64 | 72 |
65 void InitializeInternal( | 73 void InitializeInternal( |
66 const std::vector<IPEndPoint>* nameservers, | 74 const std::vector<IPEndPoint>* nameservers, |
67 NetLog* net_log); | 75 NetLog* net_log); |
68 | 76 |
69 scoped_ptr<DatagramClientSocket> CreateConnectedSocket( | 77 scoped_ptr<DatagramClientSocket> CreateConnectedSocket( |
70 unsigned server_index); | 78 unsigned server_index); |
71 | 79 |
72 private: | 80 private: |
73 ClientSocketFactory* socket_factory_; | 81 ClientSocketFactory* socket_factory_; |
74 NetLog* net_log_; | 82 NetLog* net_log_; |
75 const std::vector<IPEndPoint>* nameservers_; | 83 const std::vector<IPEndPoint>* nameservers_; |
76 bool initialized_; | 84 bool initialized_; |
77 | 85 |
78 DISALLOW_COPY_AND_ASSIGN(DnsSocketPool); | 86 DISALLOW_COPY_AND_ASSIGN(DnsSocketPool); |
79 }; | 87 }; |
80 | 88 |
81 } // namespace net | 89 } // namespace net |
82 | 90 |
83 #endif // NET_DNS_DNS_SOCKET_POOL_H_ | 91 #endif // NET_DNS_DNS_SOCKET_POOL_H_ |
OLD | NEW |