Chromium Code Reviews| Index: net/socket/socket_test_util.h |
| diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h |
| index 2918aad2dc55ec4f3b8ff5a63c0e8b584aa1af5c..d4353c59c54bc17a1f174e1c01c0ee45c15250c1 100644 |
| --- a/net/socket/socket_test_util.h |
| +++ b/net/socket/socket_test_util.h |
| @@ -335,6 +335,9 @@ struct SSLSocketDataProvider { |
| bool channel_id_sent; |
| ServerBoundCertService* server_bound_cert_service; |
| int connection_status; |
| + // Indicates that the socket should block in the Connect method. |
| + bool should_block_on_connect; |
| + bool is_in_session_cache; |
| }; |
| // A DataProvider where the client must write a request before the reads (e.g. |
| @@ -638,6 +641,12 @@ class MockClientSocketFactory : public ClientSocketFactory { |
| return mock_data_; |
| } |
| + // Note: this method is unsafe; the elements of the returned vecotor |
| + // are not necessarily valid. |
| + const std::vector<MockSSLClientSocket*>& ssl_client_sockets() const { |
| + return ssl_client_sockets_; |
| + } |
| + |
| // ClientSocketFactory |
| virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
| DatagramSocket::BindType bind_type, |
| @@ -654,10 +663,10 @@ class MockClientSocketFactory : public ClientSocketFactory { |
| const SSLConfig& ssl_config, |
| const SSLClientSocketContext& context) OVERRIDE; |
| virtual void ClearSSLSessionCache() OVERRIDE; |
| - |
| private: |
|
wtc
2014/07/23 22:53:32
Resurrect the blank line before this line.
mshelley
2014/07/24 20:37:46
Done.
|
| SocketDataProviderArray<SocketDataProvider> mock_data_; |
| SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_; |
| + std::vector<MockSSLClientSocket*> ssl_client_sockets_; |
| }; |
| class MockClientSocket : public SSLClientSocket { |
| @@ -691,6 +700,8 @@ class MockClientSocket : public SSLClientSocket { |
| virtual void SetOmniboxSpeculation() OVERRIDE {} |
| // SSLClientSocket implementation. |
| + virtual bool InSessionCache() const OVERRIDE; |
| + virtual void SetHandshakeCompletionCallback(const base::Closure& cb) OVERRIDE; |
| virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) |
| OVERRIDE; |
| virtual int ExportKeyingMaterial(const base::StringPiece& label, |
| @@ -712,6 +723,9 @@ class MockClientSocket : public SSLClientSocket { |
| virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() |
| const OVERRIDE; |
| + // Callback to be used to resume the connection of a paused socket. |
| + CompletionCallback connect_callback_; |
|
wtc
2014/07/23 22:53:32
Should this be moved to the MockSSLClientSocket cl
mshelley
2014/07/24 20:37:47
Done.
|
| + |
| // True if Connect completed successfully and Disconnect hasn't been called. |
| bool connected_; |
| @@ -950,6 +964,8 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { |
| virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; |
| // SSLClientSocket implementation. |
| + virtual bool InSessionCache() const OVERRIDE; |
| + virtual void SetHandshakeCompletionCallback(const base::Closure& cb) OVERRIDE; |
| virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) |
| OVERRIDE; |
| virtual NextProtoStatus GetNextProto(std::string* proto, |
| @@ -966,11 +982,24 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { |
| virtual void set_channel_id_sent(bool channel_id_sent) OVERRIDE; |
| virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; |
| + // Resumes the connection of a socket that was paused for testing. |
| + // |connect_callback_| should be set before invoking this method. |
| + void RestartPausedConnect(); |
| + |
| private: |
| + enum ConnectState { |
| + STATE_NONE, |
| + STATE_CONNECT, |
| + STATE_CONNECT_COMPLETE, |
| + }; |
| + |
| static void ConnectCallback(MockSSLClientSocket* ssl_client_socket, |
| const CompletionCallback& callback, |
| int rv); |
| + int DoConnect(const CompletionCallback& callback); |
| + int DoConnectComplete(const CompletionCallback& callback); |
| + |
| scoped_ptr<ClientSocketHandle> transport_; |
| SSLSocketDataProvider* data_; |
| bool is_npn_state_set_; |
| @@ -978,6 +1007,11 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { |
| bool is_protocol_negotiated_set_; |
| NextProto protocol_negotiated_; |
| + // Indicates what state of Connect the socket should enter. |
| + ConnectState next_connect_state_; |
| + |
| + base::Closure completion_callback_; |
|
wtc
2014/07/23 22:53:32
Please name this field "handshake_completion_callb
mshelley
2014/07/24 20:37:46
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); |
| }; |