OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // If the |result| member of a MockRead is | 41 // If the |result| member of a MockRead is |
42 // ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, that MockRead is just a | 42 // ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ, that MockRead is just a |
43 // marker that indicates the peer will close the connection after the next | 43 // marker that indicates the peer will close the connection after the next |
44 // MockRead. The other members of that MockRead are ignored. | 44 // MockRead. The other members of that MockRead are ignored. |
45 ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000, | 45 ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000, |
46 }; | 46 }; |
47 | 47 |
48 class ClientSocket; | 48 class ClientSocket; |
49 class MockClientSocket; | 49 class MockClientSocket; |
50 class SSLClientSocket; | 50 class SSLClientSocket; |
| 51 class SSLHostInfo; |
51 | 52 |
52 struct MockConnect { | 53 struct MockConnect { |
53 // Asynchronous connection success. | 54 // Asynchronous connection success. |
54 MockConnect() : async(true), result(OK) { } | 55 MockConnect() : async(true), result(OK) { } |
55 MockConnect(bool a, int r) : async(a), result(r) { } | 56 MockConnect(bool a, int r) : async(a), result(r) { } |
56 | 57 |
57 bool async; | 58 bool async; |
58 int result; | 59 int result; |
59 }; | 60 }; |
60 | 61 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const; | 527 MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const; |
527 | 528 |
528 // ClientSocketFactory | 529 // ClientSocketFactory |
529 virtual ClientSocket* CreateTCPClientSocket( | 530 virtual ClientSocket* CreateTCPClientSocket( |
530 const AddressList& addresses, | 531 const AddressList& addresses, |
531 NetLog* net_log, | 532 NetLog* net_log, |
532 const NetLog::Source& source); | 533 const NetLog::Source& source); |
533 virtual SSLClientSocket* CreateSSLClientSocket( | 534 virtual SSLClientSocket* CreateSSLClientSocket( |
534 ClientSocketHandle* transport_socket, | 535 ClientSocketHandle* transport_socket, |
535 const std::string& hostname, | 536 const std::string& hostname, |
536 const SSLConfig& ssl_config); | 537 const SSLConfig& ssl_config, |
| 538 SSLHostInfo* ssl_host_info); |
537 SocketDataProviderArray<SocketDataProvider>& mock_data() { | 539 SocketDataProviderArray<SocketDataProvider>& mock_data() { |
538 return mock_data_; | 540 return mock_data_; |
539 } | 541 } |
540 std::vector<MockTCPClientSocket*>& tcp_client_sockets() { | 542 std::vector<MockTCPClientSocket*>& tcp_client_sockets() { |
541 return tcp_client_sockets_; | 543 return tcp_client_sockets_; |
542 } | 544 } |
543 | 545 |
544 private: | 546 private: |
545 SocketDataProviderArray<SocketDataProvider> mock_data_; | 547 SocketDataProviderArray<SocketDataProvider> mock_data_; |
546 SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_; | 548 SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 net::DeterministicSocketData* data_; | 683 net::DeterministicSocketData* data_; |
682 bool was_used_to_convey_data_; | 684 bool was_used_to_convey_data_; |
683 }; | 685 }; |
684 | 686 |
685 class MockSSLClientSocket : public MockClientSocket { | 687 class MockSSLClientSocket : public MockClientSocket { |
686 public: | 688 public: |
687 MockSSLClientSocket( | 689 MockSSLClientSocket( |
688 net::ClientSocketHandle* transport_socket, | 690 net::ClientSocketHandle* transport_socket, |
689 const std::string& hostname, | 691 const std::string& hostname, |
690 const net::SSLConfig& ssl_config, | 692 const net::SSLConfig& ssl_config, |
| 693 SSLHostInfo* ssl_host_info, |
691 net::SSLSocketDataProvider* socket); | 694 net::SSLSocketDataProvider* socket); |
692 ~MockSSLClientSocket(); | 695 ~MockSSLClientSocket(); |
693 | 696 |
694 // ClientSocket methods: | 697 // ClientSocket methods: |
695 virtual int Connect(net::CompletionCallback* callback); | 698 virtual int Connect(net::CompletionCallback* callback); |
696 virtual void Disconnect(); | 699 virtual void Disconnect(); |
697 virtual bool IsConnected() const; | 700 virtual bool IsConnected() const; |
698 virtual bool WasEverUsed() const; | 701 virtual bool WasEverUsed() const; |
699 | 702 |
700 // Socket methods: | 703 // Socket methods: |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 // created. | 864 // created. |
862 MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const; | 865 MockSSLClientSocket* GetMockSSLClientSocket(size_t index) const; |
863 | 866 |
864 // ClientSocketFactory | 867 // ClientSocketFactory |
865 virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses, | 868 virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses, |
866 NetLog* net_log, | 869 NetLog* net_log, |
867 const NetLog::Source& source); | 870 const NetLog::Source& source); |
868 virtual SSLClientSocket* CreateSSLClientSocket( | 871 virtual SSLClientSocket* CreateSSLClientSocket( |
869 ClientSocketHandle* transport_socket, | 872 ClientSocketHandle* transport_socket, |
870 const std::string& hostname, | 873 const std::string& hostname, |
871 const SSLConfig& ssl_config); | 874 const SSLConfig& ssl_config, |
| 875 SSLHostInfo* ssl_host_info); |
872 | 876 |
873 SocketDataProviderArray<DeterministicSocketData>& mock_data() { | 877 SocketDataProviderArray<DeterministicSocketData>& mock_data() { |
874 return mock_data_; | 878 return mock_data_; |
875 } | 879 } |
876 std::vector<DeterministicMockTCPClientSocket*>& tcp_client_sockets() { | 880 std::vector<DeterministicMockTCPClientSocket*>& tcp_client_sockets() { |
877 return tcp_client_sockets_; | 881 return tcp_client_sockets_; |
878 } | 882 } |
879 | 883 |
880 private: | 884 private: |
881 SocketDataProviderArray<DeterministicSocketData> mock_data_; | 885 SocketDataProviderArray<DeterministicSocketData> mock_data_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 | 928 |
925 extern const char kSOCKS5OkRequest[]; | 929 extern const char kSOCKS5OkRequest[]; |
926 extern const int kSOCKS5OkRequestLength; | 930 extern const int kSOCKS5OkRequestLength; |
927 | 931 |
928 extern const char kSOCKS5OkResponse[]; | 932 extern const char kSOCKS5OkResponse[]; |
929 extern const int kSOCKS5OkResponseLength; | 933 extern const int kSOCKS5OkResponseLength; |
930 | 934 |
931 } // namespace net | 935 } // namespace net |
932 | 936 |
933 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 937 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |