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