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