OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SOCKET_TEST_UTIL_H_ | 5 #ifndef NET_SOCKET_SOCKET_TEST_UTIL_H_ |
6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ | 6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // to Connect(). | 343 // to Connect(). |
344 struct SSLSocketDataProvider { | 344 struct SSLSocketDataProvider { |
345 SSLSocketDataProvider(IoMode mode, int result); | 345 SSLSocketDataProvider(IoMode mode, int result); |
346 ~SSLSocketDataProvider(); | 346 ~SSLSocketDataProvider(); |
347 | 347 |
348 void SetNextProto(NextProto proto); | 348 void SetNextProto(NextProto proto); |
349 | 349 |
350 MockConnect connect; | 350 MockConnect connect; |
351 SSLClientSocket::NextProtoStatus next_proto_status; | 351 SSLClientSocket::NextProtoStatus next_proto_status; |
352 std::string next_proto; | 352 std::string next_proto; |
353 bool was_npn_negotiated; | |
354 NextProto protocol_negotiated; | |
355 NextProtoVector next_protos_expected_in_ssl_config; | 353 NextProtoVector next_protos_expected_in_ssl_config; |
356 bool client_cert_sent; | 354 bool client_cert_sent; |
357 SSLCertRequestInfo* cert_request_info; | 355 SSLCertRequestInfo* cert_request_info; |
358 scoped_refptr<X509Certificate> cert; | 356 scoped_refptr<X509Certificate> cert; |
359 bool channel_id_sent; | 357 bool channel_id_sent; |
360 ChannelIDService* channel_id_service; | 358 ChannelIDService* channel_id_service; |
361 int connection_status; | 359 int connection_status; |
362 }; | 360 }; |
363 | 361 |
364 // A DataProvider where the client must write a request before the reads (e.g. | 362 // A DataProvider where the client must write a request before the reads (e.g. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 void SetOmniboxSpeculation() override {} | 713 void SetOmniboxSpeculation() override {} |
716 | 714 |
717 // SSLClientSocket implementation. | 715 // SSLClientSocket implementation. |
718 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; | 716 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
719 int ExportKeyingMaterial(const base::StringPiece& label, | 717 int ExportKeyingMaterial(const base::StringPiece& label, |
720 bool has_context, | 718 bool has_context, |
721 const base::StringPiece& context, | 719 const base::StringPiece& context, |
722 unsigned char* out, | 720 unsigned char* out, |
723 unsigned int outlen) override; | 721 unsigned int outlen) override; |
724 int GetTLSUniqueChannelBinding(std::string* out) override; | 722 int GetTLSUniqueChannelBinding(std::string* out) override; |
725 NextProtoStatus GetNextProto(std::string* proto) override; | 723 NextProtoStatus GetNextProto(std::string* proto) const override; |
726 ChannelIDService* GetChannelIDService() const override; | 724 ChannelIDService* GetChannelIDService() const override; |
727 | 725 |
728 protected: | 726 protected: |
729 ~MockClientSocket() override; | 727 ~MockClientSocket() override; |
730 void RunCallbackAsync(const CompletionCallback& callback, int result); | 728 void RunCallbackAsync(const CompletionCallback& callback, int result); |
731 void RunCallback(const CompletionCallback& callback, int result); | 729 void RunCallback(const CompletionCallback& callback, int result); |
732 | 730 |
733 // SSLClientSocket implementation. | 731 // SSLClientSocket implementation. |
734 scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() | 732 scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() |
735 const override; | 733 const override; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 int buf_len, | 960 int buf_len, |
963 const CompletionCallback& callback) override; | 961 const CompletionCallback& callback) override; |
964 | 962 |
965 // StreamSocket implementation. | 963 // StreamSocket implementation. |
966 int Connect(const CompletionCallback& callback) override; | 964 int Connect(const CompletionCallback& callback) override; |
967 void Disconnect() override; | 965 void Disconnect() override; |
968 bool IsConnected() const override; | 966 bool IsConnected() const override; |
969 bool WasEverUsed() const override; | 967 bool WasEverUsed() const override; |
970 bool UsingTCPFastOpen() const override; | 968 bool UsingTCPFastOpen() const override; |
971 int GetPeerAddress(IPEndPoint* address) const override; | 969 int GetPeerAddress(IPEndPoint* address) const override; |
972 bool WasNpnNegotiated() const override; | |
973 bool GetSSLInfo(SSLInfo* ssl_info) override; | 970 bool GetSSLInfo(SSLInfo* ssl_info) override; |
974 | 971 |
975 // SSLClientSocket implementation. | 972 // SSLClientSocket implementation. |
976 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; | 973 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
977 NextProtoStatus GetNextProto(std::string* proto) override; | 974 NextProtoStatus GetNextProto(std::string* proto) const override; |
978 bool set_was_npn_negotiated(bool negotiated) override; | |
979 void set_protocol_negotiated(NextProto protocol_negotiated) override; | |
980 NextProto GetNegotiatedProtocol() const override; | |
981 | 975 |
982 // This MockSocket does not implement the manual async IO feature. | 976 // This MockSocket does not implement the manual async IO feature. |
983 void OnReadComplete(const MockRead& data) override; | 977 void OnReadComplete(const MockRead& data) override; |
984 void OnConnectComplete(const MockConnect& data) override; | 978 void OnConnectComplete(const MockConnect& data) override; |
985 | 979 |
986 bool WasChannelIDSent() const override; | 980 bool WasChannelIDSent() const override; |
987 void set_channel_id_sent(bool channel_id_sent) override; | 981 void set_channel_id_sent(bool channel_id_sent) override; |
988 ChannelIDService* GetChannelIDService() const override; | 982 ChannelIDService* GetChannelIDService() const override; |
989 | 983 |
990 private: | 984 private: |
991 static void ConnectCallback(MockSSLClientSocket* ssl_client_socket, | 985 static void ConnectCallback(MockSSLClientSocket* ssl_client_socket, |
992 const CompletionCallback& callback, | 986 const CompletionCallback& callback, |
993 int rv); | 987 int rv); |
994 | 988 |
995 scoped_ptr<ClientSocketHandle> transport_; | 989 scoped_ptr<ClientSocketHandle> transport_; |
996 SSLSocketDataProvider* data_; | 990 SSLSocketDataProvider* data_; |
997 bool is_npn_state_set_; | |
998 bool new_npn_value_; | |
999 bool is_protocol_negotiated_set_; | |
1000 NextProto protocol_negotiated_; | |
1001 | 991 |
1002 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); | 992 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocket); |
1003 }; | 993 }; |
1004 | 994 |
1005 class MockUDPClientSocket : public DatagramClientSocket, public AsyncSocket { | 995 class MockUDPClientSocket : public DatagramClientSocket, public AsyncSocket { |
1006 public: | 996 public: |
1007 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log); | 997 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log); |
1008 ~MockUDPClientSocket() override; | 998 ~MockUDPClientSocket() override; |
1009 | 999 |
1010 // Socket implementation. | 1000 // Socket implementation. |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 | 1306 |
1317 extern const char kSOCKS5OkRequest[]; | 1307 extern const char kSOCKS5OkRequest[]; |
1318 extern const int kSOCKS5OkRequestLength; | 1308 extern const int kSOCKS5OkRequestLength; |
1319 | 1309 |
1320 extern const char kSOCKS5OkResponse[]; | 1310 extern const char kSOCKS5OkResponse[]; |
1321 extern const int kSOCKS5OkResponseLength; | 1311 extern const int kSOCKS5OkResponseLength; |
1322 | 1312 |
1323 } // namespace net | 1313 } // namespace net |
1324 | 1314 |
1325 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1315 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |