| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 MockClientSocket; | 50 class MockClientSocket; |
| 51 class OriginBoundCertService; | 51 class ServerBoundCertService; |
| 52 class SSLClientSocket; | 52 class SSLClientSocket; |
| 53 class SSLHostInfo; | 53 class SSLHostInfo; |
| 54 class StreamSocket; | 54 class StreamSocket; |
| 55 | 55 |
| 56 enum IoMode { | 56 enum IoMode { |
| 57 ASYNC, | 57 ASYNC, |
| 58 SYNCHRONOUS | 58 SYNCHRONOUS |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 struct MockConnect { | 61 struct MockConnect { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 MockConnect connect; | 274 MockConnect connect; |
| 275 SSLClientSocket::NextProtoStatus next_proto_status; | 275 SSLClientSocket::NextProtoStatus next_proto_status; |
| 276 std::string next_proto; | 276 std::string next_proto; |
| 277 std::string server_protos; | 277 std::string server_protos; |
| 278 bool was_npn_negotiated; | 278 bool was_npn_negotiated; |
| 279 SSLClientSocket::NextProto protocol_negotiated; | 279 SSLClientSocket::NextProto protocol_negotiated; |
| 280 bool client_cert_sent; | 280 bool client_cert_sent; |
| 281 SSLCertRequestInfo* cert_request_info; | 281 SSLCertRequestInfo* cert_request_info; |
| 282 scoped_refptr<X509Certificate> cert; | 282 scoped_refptr<X509Certificate> cert; |
| 283 SSLClientCertType origin_bound_cert_type; | 283 SSLClientCertType domain_bound_cert_type; |
| 284 OriginBoundCertService* origin_bound_cert_service; | 284 ServerBoundCertService* server_bound_cert_service; |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 // A DataProvider where the client must write a request before the reads (e.g. | 287 // A DataProvider where the client must write a request before the reads (e.g. |
| 288 // the response) will complete. | 288 // the response) will complete. |
| 289 class DelayedSocketData : public StaticSocketDataProvider { | 289 class DelayedSocketData : public StaticSocketDataProvider { |
| 290 public: | 290 public: |
| 291 // |write_delay| the number of MockWrites to complete before allowing | 291 // |write_delay| the number of MockWrites to complete before allowing |
| 292 // a MockRead to complete. | 292 // a MockRead to complete. |
| 293 // |reads| the list of MockRead completions. | 293 // |reads| the list of MockRead completions. |
| 294 // |writes| the list of MockWrite completions. | 294 // |writes| the list of MockWrite completions. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; | 595 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; |
| 596 virtual void GetSSLCertRequestInfo( | 596 virtual void GetSSLCertRequestInfo( |
| 597 SSLCertRequestInfo* cert_request_info) OVERRIDE; | 597 SSLCertRequestInfo* cert_request_info) OVERRIDE; |
| 598 virtual int ExportKeyingMaterial(const base::StringPiece& label, | 598 virtual int ExportKeyingMaterial(const base::StringPiece& label, |
| 599 bool has_context, | 599 bool has_context, |
| 600 const base::StringPiece& context, | 600 const base::StringPiece& context, |
| 601 unsigned char* out, | 601 unsigned char* out, |
| 602 unsigned int outlen) OVERRIDE; | 602 unsigned int outlen) OVERRIDE; |
| 603 virtual NextProtoStatus GetNextProto(std::string* proto, | 603 virtual NextProtoStatus GetNextProto(std::string* proto, |
| 604 std::string* server_protos) OVERRIDE; | 604 std::string* server_protos) OVERRIDE; |
| 605 virtual OriginBoundCertService* GetOriginBoundCertService() const OVERRIDE; | 605 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; |
| 606 | 606 |
| 607 protected: | 607 protected: |
| 608 virtual ~MockClientSocket(); | 608 virtual ~MockClientSocket(); |
| 609 void RunCallbackAsync(const CompletionCallback& callback, int result); | 609 void RunCallbackAsync(const CompletionCallback& callback, int result); |
| 610 void RunCallback(const CompletionCallback& callback, int result); | 610 void RunCallback(const CompletionCallback& callback, int result); |
| 611 | 611 |
| 612 base::WeakPtrFactory<MockClientSocket> weak_factory_; | 612 base::WeakPtrFactory<MockClientSocket> weak_factory_; |
| 613 | 613 |
| 614 // True if Connect completed successfully and Disconnect hasn't been called. | 614 // True if Connect completed successfully and Disconnect hasn't been called. |
| 615 bool connected_; | 615 bool connected_; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 std::string* server_protos) OVERRIDE; | 750 std::string* server_protos) OVERRIDE; |
| 751 virtual bool was_npn_negotiated() const OVERRIDE; | 751 virtual bool was_npn_negotiated() const OVERRIDE; |
| 752 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; | 752 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; |
| 753 virtual SSLClientSocket::NextProto protocol_negotiated() const OVERRIDE; | 753 virtual SSLClientSocket::NextProto protocol_negotiated() const OVERRIDE; |
| 754 virtual void set_protocol_negotiated( | 754 virtual void set_protocol_negotiated( |
| 755 SSLClientSocket::NextProto protocol_negotiated) OVERRIDE; | 755 SSLClientSocket::NextProto protocol_negotiated) OVERRIDE; |
| 756 | 756 |
| 757 // This MockSocket does not implement the manual async IO feature. | 757 // This MockSocket does not implement the manual async IO feature. |
| 758 virtual void OnReadComplete(const MockRead& data) OVERRIDE; | 758 virtual void OnReadComplete(const MockRead& data) OVERRIDE; |
| 759 | 759 |
| 760 virtual bool WasOriginBoundCertSent() const OVERRIDE; | 760 virtual bool WasDomainBoundCertSent() const OVERRIDE; |
| 761 virtual SSLClientCertType origin_bound_cert_type() const OVERRIDE; | 761 virtual SSLClientCertType domain_bound_cert_type() const OVERRIDE; |
| 762 virtual SSLClientCertType set_origin_bound_cert_type( | 762 virtual SSLClientCertType set_domain_bound_cert_type( |
| 763 SSLClientCertType type) OVERRIDE; | 763 SSLClientCertType type) OVERRIDE; |
| 764 virtual OriginBoundCertService* GetOriginBoundCertService() const OVERRIDE; | 764 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; |
| 765 | 765 |
| 766 private: | 766 private: |
| 767 static void ConnectCallback(MockSSLClientSocket *ssl_client_socket, | 767 static void ConnectCallback(MockSSLClientSocket *ssl_client_socket, |
| 768 const CompletionCallback& callback, | 768 const CompletionCallback& callback, |
| 769 int rv); | 769 int rv); |
| 770 | 770 |
| 771 scoped_ptr<ClientSocketHandle> transport_; | 771 scoped_ptr<ClientSocketHandle> transport_; |
| 772 SSLSocketDataProvider* data_; | 772 SSLSocketDataProvider* data_; |
| 773 bool is_npn_state_set_; | 773 bool is_npn_state_set_; |
| 774 bool new_npn_value_; | 774 bool new_npn_value_; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 | 1043 |
| 1044 extern const char kSOCKS5OkRequest[]; | 1044 extern const char kSOCKS5OkRequest[]; |
| 1045 extern const int kSOCKS5OkRequestLength; | 1045 extern const int kSOCKS5OkRequestLength; |
| 1046 | 1046 |
| 1047 extern const char kSOCKS5OkResponse[]; | 1047 extern const char kSOCKS5OkResponse[]; |
| 1048 extern const int kSOCKS5OkResponseLength; | 1048 extern const int kSOCKS5OkResponseLength; |
| 1049 | 1049 |
| 1050 } // namespace net | 1050 } // namespace net |
| 1051 | 1051 |
| 1052 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1052 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
| OLD | NEW |