| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 594   // SSLClientSocket implementation. | 594   // SSLClientSocket implementation. | 
| 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                                    const base::StringPiece& context, | 599                                    const base::StringPiece& context, | 
| 600                                    unsigned char *out, | 600                                    unsigned char *out, | 
| 601                                    unsigned int outlen) OVERRIDE; | 601                                    unsigned int outlen) OVERRIDE; | 
| 602   virtual NextProtoStatus GetNextProto(std::string* proto, | 602   virtual NextProtoStatus GetNextProto(std::string* proto, | 
| 603                                        std::string* server_protos) OVERRIDE; | 603                                        std::string* server_protos) OVERRIDE; | 
| 604   virtual OriginBoundCertService* GetOriginBoundCertService() const OVERRIDE; | 604   virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; | 
| 605 | 605 | 
| 606  protected: | 606  protected: | 
| 607   virtual ~MockClientSocket(); | 607   virtual ~MockClientSocket(); | 
| 608   void RunCallbackAsync(const CompletionCallback& callback, int result); | 608   void RunCallbackAsync(const CompletionCallback& callback, int result); | 
| 609   void RunCallback(const CompletionCallback& callback, int result); | 609   void RunCallback(const CompletionCallback& callback, int result); | 
| 610 | 610 | 
| 611   base::WeakPtrFactory<MockClientSocket> weak_factory_; | 611   base::WeakPtrFactory<MockClientSocket> weak_factory_; | 
| 612 | 612 | 
| 613   // True if Connect completed successfully and Disconnect hasn't been called. | 613   // True if Connect completed successfully and Disconnect hasn't been called. | 
| 614   bool connected_; | 614   bool connected_; | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 749                                        std::string* server_protos) OVERRIDE; | 749                                        std::string* server_protos) OVERRIDE; | 
| 750   virtual bool was_npn_negotiated() const OVERRIDE; | 750   virtual bool was_npn_negotiated() const OVERRIDE; | 
| 751   virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; | 751   virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; | 
| 752   virtual SSLClientSocket::NextProto protocol_negotiated() const OVERRIDE; | 752   virtual SSLClientSocket::NextProto protocol_negotiated() const OVERRIDE; | 
| 753   virtual void set_protocol_negotiated( | 753   virtual void set_protocol_negotiated( | 
| 754       SSLClientSocket::NextProto protocol_negotiated) OVERRIDE; | 754       SSLClientSocket::NextProto protocol_negotiated) OVERRIDE; | 
| 755 | 755 | 
| 756   // This MockSocket does not implement the manual async IO feature. | 756   // This MockSocket does not implement the manual async IO feature. | 
| 757   virtual void OnReadComplete(const MockRead& data) OVERRIDE; | 757   virtual void OnReadComplete(const MockRead& data) OVERRIDE; | 
| 758 | 758 | 
| 759   virtual bool WasOriginBoundCertSent() const OVERRIDE; | 759   virtual bool WasDomainBoundCertSent() const OVERRIDE; | 
| 760   virtual SSLClientCertType origin_bound_cert_type() const OVERRIDE; | 760   virtual SSLClientCertType domain_bound_cert_type() const OVERRIDE; | 
| 761   virtual SSLClientCertType set_origin_bound_cert_type( | 761   virtual SSLClientCertType set_domain_bound_cert_type( | 
| 762       SSLClientCertType type) OVERRIDE; | 762       SSLClientCertType type) OVERRIDE; | 
| 763   virtual OriginBoundCertService* GetOriginBoundCertService() const OVERRIDE; | 763   virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; | 
| 764 | 764 | 
| 765  private: | 765  private: | 
| 766   static void ConnectCallback(MockSSLClientSocket *ssl_client_socket, | 766   static void ConnectCallback(MockSSLClientSocket *ssl_client_socket, | 
| 767                               const CompletionCallback& callback, | 767                               const CompletionCallback& callback, | 
| 768                               int rv); | 768                               int rv); | 
| 769 | 769 | 
| 770   scoped_ptr<ClientSocketHandle> transport_; | 770   scoped_ptr<ClientSocketHandle> transport_; | 
| 771   SSLSocketDataProvider* data_; | 771   SSLSocketDataProvider* data_; | 
| 772   bool is_npn_state_set_; | 772   bool is_npn_state_set_; | 
| 773   bool new_npn_value_; | 773   bool new_npn_value_; | 
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1042 | 1042 | 
| 1043 extern const char kSOCKS5OkRequest[]; | 1043 extern const char kSOCKS5OkRequest[]; | 
| 1044 extern const int kSOCKS5OkRequestLength; | 1044 extern const int kSOCKS5OkRequestLength; | 
| 1045 | 1045 | 
| 1046 extern const char kSOCKS5OkResponse[]; | 1046 extern const char kSOCKS5OkResponse[]; | 
| 1047 extern const int kSOCKS5OkResponseLength; | 1047 extern const int kSOCKS5OkResponseLength; | 
| 1048 | 1048 | 
| 1049 }  // namespace net | 1049 }  // namespace net | 
| 1050 | 1050 | 
| 1051 #endif  // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1051 #endif  // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 
| OLD | NEW | 
|---|