| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Test methods and classes common to transport_client_socket_pool_unittest.cc | 5 // Test methods and classes common to transport_client_socket_pool_unittest.cc |
| 6 // and websocket_transport_client_socket_pool_unittest.cc. If you find you need | 6 // and websocket_transport_client_socket_pool_unittest.cc. If you find you need |
| 7 // to use these for another purpose, consider moving them to socket_test_util.h. | 7 // to use these for another purpose, consider moving them to socket_test_util.h. |
| 8 | 8 |
| 9 #ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ | 9 #ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ |
| 10 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ | 10 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ |
| 11 | 11 |
| 12 #include <memory> |
| 12 #include <queue> | 13 #include <queue> |
| 13 | 14 |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
| 20 #include "net/base/socket_performance_watcher.h" | 20 #include "net/base/socket_performance_watcher.h" |
| 21 #include "net/log/net_log.h" | 21 #include "net/log/net_log.h" |
| 22 #include "net/socket/client_socket_factory.h" | 22 #include "net/socket/client_socket_factory.h" |
| 23 #include "net/socket/client_socket_handle.h" | 23 #include "net/socket/client_socket_handle.h" |
| 24 #include "net/socket/stream_socket.h" | 24 #include "net/socket/stream_socket.h" |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 | 27 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // A stalled socket that never connects at all, but returns a failing | 66 // A stalled socket that never connects at all, but returns a failing |
| 67 // ConnectionAttempt in |GetConnectionAttempts|. | 67 // ConnectionAttempt in |GetConnectionAttempts|. |
| 68 MOCK_STALLED_FAILING_CLIENT_SOCKET, | 68 MOCK_STALLED_FAILING_CLIENT_SOCKET, |
| 69 // A socket that can be triggered to connect explicitly, asynchronously. | 69 // A socket that can be triggered to connect explicitly, asynchronously. |
| 70 MOCK_TRIGGERABLE_CLIENT_SOCKET, | 70 MOCK_TRIGGERABLE_CLIENT_SOCKET, |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 explicit MockTransportClientSocketFactory(NetLog* net_log); | 73 explicit MockTransportClientSocketFactory(NetLog* net_log); |
| 74 ~MockTransportClientSocketFactory() override; | 74 ~MockTransportClientSocketFactory() override; |
| 75 | 75 |
| 76 scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( | 76 std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
| 77 DatagramSocket::BindType bind_type, | 77 DatagramSocket::BindType bind_type, |
| 78 const RandIntCallback& rand_int_cb, | 78 const RandIntCallback& rand_int_cb, |
| 79 NetLog* net_log, | 79 NetLog* net_log, |
| 80 const NetLog::Source& source) override; | 80 const NetLog::Source& source) override; |
| 81 | 81 |
| 82 scoped_ptr<StreamSocket> CreateTransportClientSocket( | 82 std::unique_ptr<StreamSocket> CreateTransportClientSocket( |
| 83 const AddressList& addresses, | 83 const AddressList& addresses, |
| 84 scoped_ptr<SocketPerformanceWatcher> /* socket_performance_watcher */, | 84 std::unique_ptr< |
| 85 SocketPerformanceWatcher> /* socket_performance_watcher */, |
| 85 NetLog* /* net_log */, | 86 NetLog* /* net_log */, |
| 86 const NetLog::Source& /* source */) override; | 87 const NetLog::Source& /* source */) override; |
| 87 | 88 |
| 88 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( | 89 std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 89 scoped_ptr<ClientSocketHandle> transport_socket, | 90 std::unique_ptr<ClientSocketHandle> transport_socket, |
| 90 const HostPortPair& host_and_port, | 91 const HostPortPair& host_and_port, |
| 91 const SSLConfig& ssl_config, | 92 const SSLConfig& ssl_config, |
| 92 const SSLClientSocketContext& context) override; | 93 const SSLClientSocketContext& context) override; |
| 93 | 94 |
| 94 void ClearSSLSessionCache() override; | 95 void ClearSSLSessionCache() override; |
| 95 | 96 |
| 96 int allocation_count() const { return allocation_count_; } | 97 int allocation_count() const { return allocation_count_; } |
| 97 | 98 |
| 98 // Set the default ClientSocketType. | 99 // Set the default ClientSocketType. |
| 99 void set_default_client_socket_type(ClientSocketType type) { | 100 void set_default_client_socket_type(ClientSocketType type) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 123 base::TimeDelta delay_; | 124 base::TimeDelta delay_; |
| 124 std::queue<base::Closure> triggerable_sockets_; | 125 std::queue<base::Closure> triggerable_sockets_; |
| 125 base::Closure run_loop_quit_closure_; | 126 base::Closure run_loop_quit_closure_; |
| 126 | 127 |
| 127 DISALLOW_COPY_AND_ASSIGN(MockTransportClientSocketFactory); | 128 DISALLOW_COPY_AND_ASSIGN(MockTransportClientSocketFactory); |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 } // namespace net | 131 } // namespace net |
| 131 | 132 |
| 132 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ | 133 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_TEST_UTIL_H_ |
| OLD | NEW |