OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 #include "net/base/rand_callback.h" | 12 #include "net/base/rand_callback.h" |
13 #include "net/log/net_log.h" | |
14 #include "net/socket/socket_performance_watcher.h" | 13 #include "net/socket/socket_performance_watcher.h" |
15 #include "net/udp/datagram_socket.h" | 14 #include "net/udp/datagram_socket.h" |
16 | 15 |
17 namespace net { | 16 namespace net { |
18 | 17 |
19 class AddressList; | 18 class AddressList; |
20 class ClientSocketHandle; | 19 class ClientSocketHandle; |
21 class DatagramClientSocket; | 20 class DatagramClientSocket; |
22 class HostPortPair; | 21 class HostPortPair; |
| 22 class NetLog; |
| 23 struct NetLogSource; |
23 class SSLClientSocket; | 24 class SSLClientSocket; |
24 struct SSLClientSocketContext; | 25 struct SSLClientSocketContext; |
25 struct SSLConfig; | 26 struct SSLConfig; |
26 class StreamSocket; | 27 class StreamSocket; |
27 | 28 |
28 // An interface used to instantiate StreamSocket objects. Used to facilitate | 29 // An interface used to instantiate StreamSocket objects. Used to facilitate |
29 // testing code with mock socket implementations. | 30 // testing code with mock socket implementations. |
30 class NET_EXPORT ClientSocketFactory { | 31 class NET_EXPORT ClientSocketFactory { |
31 public: | 32 public: |
32 virtual ~ClientSocketFactory() {} | 33 virtual ~ClientSocketFactory() {} |
33 | 34 |
34 // |source| is the NetLog::Source for the entity trying to create the socket, | 35 // |source| is the NetLogSource for the entity trying to create the socket, |
35 // if it has one. | 36 // if it has one. |
36 virtual std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( | 37 virtual std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
37 DatagramSocket::BindType bind_type, | 38 DatagramSocket::BindType bind_type, |
38 const RandIntCallback& rand_int_cb, | 39 const RandIntCallback& rand_int_cb, |
39 NetLog* net_log, | 40 NetLog* net_log, |
40 const NetLog::Source& source) = 0; | 41 const NetLogSource& source) = 0; |
41 | 42 |
42 virtual std::unique_ptr<StreamSocket> CreateTransportClientSocket( | 43 virtual std::unique_ptr<StreamSocket> CreateTransportClientSocket( |
43 const AddressList& addresses, | 44 const AddressList& addresses, |
44 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 45 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
45 NetLog* net_log, | 46 NetLog* net_log, |
46 const NetLog::Source& source) = 0; | 47 const NetLogSource& source) = 0; |
47 | 48 |
48 // It is allowed to pass in a |transport_socket| that is not obtained from a | 49 // It is allowed to pass in a |transport_socket| that is not obtained from a |
49 // socket pool. The caller could create a ClientSocketHandle directly and call | 50 // socket pool. The caller could create a ClientSocketHandle directly and call |
50 // set_socket() on it to set a valid StreamSocket instance. | 51 // set_socket() on it to set a valid StreamSocket instance. |
51 virtual std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( | 52 virtual std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( |
52 std::unique_ptr<ClientSocketHandle> transport_socket, | 53 std::unique_ptr<ClientSocketHandle> transport_socket, |
53 const HostPortPair& host_and_port, | 54 const HostPortPair& host_and_port, |
54 const SSLConfig& ssl_config, | 55 const SSLConfig& ssl_config, |
55 const SSLClientSocketContext& context) = 0; | 56 const SSLClientSocketContext& context) = 0; |
56 | 57 |
57 // Clears cache used for SSL session resumption. | 58 // Clears cache used for SSL session resumption. |
58 virtual void ClearSSLSessionCache() = 0; | 59 virtual void ClearSSLSessionCache() = 0; |
59 | 60 |
60 // Returns the default ClientSocketFactory. | 61 // Returns the default ClientSocketFactory. |
61 static ClientSocketFactory* GetDefaultFactory(); | 62 static ClientSocketFactory* GetDefaultFactory(); |
62 }; | 63 }; |
63 | 64 |
64 } // namespace net | 65 } // namespace net |
65 | 66 |
66 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ | 67 #endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_ |
OLD | NEW |