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 29 matching lines...) Expand all Loading... |
40 enum { | 40 enum { |
41 // A private network error code used by the socket test utility classes. | 41 // A private network error code used by the socket test utility classes. |
42 // If the |result| member of a MockRead is | 42 // If the |result| member of a MockRead is |
43 // ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, that MockRead is just a | 43 // ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, that MockRead is just a |
44 // marker that indicates the peer will close the connection after the next | 44 // marker that indicates the peer will close the connection after the next |
45 // MockRead. The other members of that MockRead are ignored. | 45 // MockRead. The other members of that MockRead are ignored. |
46 ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000, | 46 ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000, |
47 }; | 47 }; |
48 | 48 |
49 class AsyncSocket; | 49 class AsyncSocket; |
| 50 class ChannelIDService; |
50 class MockClientSocket; | 51 class MockClientSocket; |
51 class ServerBoundCertService; | |
52 class SSLClientSocket; | 52 class SSLClientSocket; |
53 class StreamSocket; | 53 class StreamSocket; |
54 | 54 |
55 enum IoMode { | 55 enum IoMode { |
56 ASYNC, | 56 ASYNC, |
57 SYNCHRONOUS | 57 SYNCHRONOUS |
58 }; | 58 }; |
59 | 59 |
60 struct MockConnect { | 60 struct MockConnect { |
61 // Asynchronous connection success. | 61 // Asynchronous connection success. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 MockConnect connect; | 326 MockConnect connect; |
327 SSLClientSocket::NextProtoStatus next_proto_status; | 327 SSLClientSocket::NextProtoStatus next_proto_status; |
328 std::string next_proto; | 328 std::string next_proto; |
329 std::string server_protos; | 329 std::string server_protos; |
330 bool was_npn_negotiated; | 330 bool was_npn_negotiated; |
331 NextProto protocol_negotiated; | 331 NextProto protocol_negotiated; |
332 bool client_cert_sent; | 332 bool client_cert_sent; |
333 SSLCertRequestInfo* cert_request_info; | 333 SSLCertRequestInfo* cert_request_info; |
334 scoped_refptr<X509Certificate> cert; | 334 scoped_refptr<X509Certificate> cert; |
335 bool channel_id_sent; | 335 bool channel_id_sent; |
336 ServerBoundCertService* server_bound_cert_service; | 336 ChannelIDService* channel_id_service; |
337 int connection_status; | 337 int connection_status; |
338 }; | 338 }; |
339 | 339 |
340 // A DataProvider where the client must write a request before the reads (e.g. | 340 // A DataProvider where the client must write a request before the reads (e.g. |
341 // the response) will complete. | 341 // the response) will complete. |
342 class DelayedSocketData : public StaticSocketDataProvider { | 342 class DelayedSocketData : public StaticSocketDataProvider { |
343 public: | 343 public: |
344 // |write_delay| the number of MockWrites to complete before allowing | 344 // |write_delay| the number of MockWrites to complete before allowing |
345 // a MockRead to complete. | 345 // a MockRead to complete. |
346 // |reads| the list of MockRead completions. | 346 // |reads| the list of MockRead completions. |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) | 694 virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) |
695 OVERRIDE; | 695 OVERRIDE; |
696 virtual int ExportKeyingMaterial(const base::StringPiece& label, | 696 virtual int ExportKeyingMaterial(const base::StringPiece& label, |
697 bool has_context, | 697 bool has_context, |
698 const base::StringPiece& context, | 698 const base::StringPiece& context, |
699 unsigned char* out, | 699 unsigned char* out, |
700 unsigned int outlen) OVERRIDE; | 700 unsigned int outlen) OVERRIDE; |
701 virtual int GetTLSUniqueChannelBinding(std::string* out) OVERRIDE; | 701 virtual int GetTLSUniqueChannelBinding(std::string* out) OVERRIDE; |
702 virtual NextProtoStatus GetNextProto(std::string* proto, | 702 virtual NextProtoStatus GetNextProto(std::string* proto, |
703 std::string* server_protos) OVERRIDE; | 703 std::string* server_protos) OVERRIDE; |
704 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; | 704 virtual ChannelIDService* GetChannelIDService() const OVERRIDE; |
705 | 705 |
706 protected: | 706 protected: |
707 virtual ~MockClientSocket(); | 707 virtual ~MockClientSocket(); |
708 void RunCallbackAsync(const CompletionCallback& callback, int result); | 708 void RunCallbackAsync(const CompletionCallback& callback, int result); |
709 void RunCallback(const CompletionCallback& callback, int result); | 709 void RunCallback(const CompletionCallback& callback, int result); |
710 | 710 |
711 // SSLClientSocket implementation. | 711 // SSLClientSocket implementation. |
712 virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() | 712 virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() |
713 const OVERRIDE; | 713 const OVERRIDE; |
714 | 714 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; | 957 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; |
958 virtual void set_protocol_negotiated(NextProto protocol_negotiated) OVERRIDE; | 958 virtual void set_protocol_negotiated(NextProto protocol_negotiated) OVERRIDE; |
959 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; | 959 virtual NextProto GetNegotiatedProtocol() const OVERRIDE; |
960 | 960 |
961 // This MockSocket does not implement the manual async IO feature. | 961 // This MockSocket does not implement the manual async IO feature. |
962 virtual void OnReadComplete(const MockRead& data) OVERRIDE; | 962 virtual void OnReadComplete(const MockRead& data) OVERRIDE; |
963 virtual void OnConnectComplete(const MockConnect& data) OVERRIDE; | 963 virtual void OnConnectComplete(const MockConnect& data) OVERRIDE; |
964 | 964 |
965 virtual bool WasChannelIDSent() const OVERRIDE; | 965 virtual bool WasChannelIDSent() const OVERRIDE; |
966 virtual void set_channel_id_sent(bool channel_id_sent) OVERRIDE; | 966 virtual void set_channel_id_sent(bool channel_id_sent) OVERRIDE; |
967 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; | 967 virtual ChannelIDService* GetChannelIDService() const OVERRIDE; |
968 | 968 |
969 private: | 969 private: |
970 static void ConnectCallback(MockSSLClientSocket* ssl_client_socket, | 970 static void ConnectCallback(MockSSLClientSocket* ssl_client_socket, |
971 const CompletionCallback& callback, | 971 const CompletionCallback& callback, |
972 int rv); | 972 int rv); |
973 | 973 |
974 scoped_ptr<ClientSocketHandle> transport_; | 974 scoped_ptr<ClientSocketHandle> transport_; |
975 SSLSocketDataProvider* data_; | 975 SSLSocketDataProvider* data_; |
976 bool is_npn_state_set_; | 976 bool is_npn_state_set_; |
977 bool new_npn_value_; | 977 bool new_npn_value_; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 | 1285 |
1286 extern const char kSOCKS5OkRequest[]; | 1286 extern const char kSOCKS5OkRequest[]; |
1287 extern const int kSOCKS5OkRequestLength; | 1287 extern const int kSOCKS5OkRequestLength; |
1288 | 1288 |
1289 extern const char kSOCKS5OkResponse[]; | 1289 extern const char kSOCKS5OkResponse[]; |
1290 extern const int kSOCKS5OkResponseLength; | 1290 extern const int kSOCKS5OkResponseLength; |
1291 | 1291 |
1292 } // namespace net | 1292 } // namespace net |
1293 | 1293 |
1294 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1294 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |