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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Read success (inferred data length). | 85 // Read success (inferred data length). |
86 MockRead(bool async, const char* data) : async(async), result(0), data(data), | 86 MockRead(bool async, const char* data) : async(async), result(0), data(data), |
87 data_len(strlen(data)), sequence_number(0), | 87 data_len(strlen(data)), sequence_number(0), |
88 time_stamp(base::Time::Now()) { } | 88 time_stamp(base::Time::Now()) { } |
89 | 89 |
90 // Read success. | 90 // Read success. |
91 MockRead(bool async, const char* data, int data_len) : async(async), | 91 MockRead(bool async, const char* data, int data_len) : async(async), |
92 result(0), data(data), data_len(data_len), sequence_number(0), | 92 result(0), data(data), data_len(data_len), sequence_number(0), |
93 time_stamp(base::Time::Now()) { } | 93 time_stamp(base::Time::Now()) { } |
94 | 94 |
| 95 // Read success (inferred data length) with sequence information. |
| 96 MockRead(bool async, int seq, const char* data) : async(async), |
| 97 result(0), data(data), data_len(strlen(data)), sequence_number(seq), |
| 98 time_stamp(base::Time::Now()) { } |
| 99 |
95 // Read success with sequence information. | 100 // Read success with sequence information. |
96 MockRead(bool async, const char* data, int data_len, int seq) : async(async), | 101 MockRead(bool async, const char* data, int data_len, int seq) : async(async), |
97 result(0), data(data), data_len(data_len), sequence_number(seq), | 102 result(0), data(data), data_len(data_len), sequence_number(seq), |
98 time_stamp(base::Time::Now()) { } | 103 time_stamp(base::Time::Now()) { } |
99 | 104 |
100 bool async; | 105 bool async; |
101 int result; | 106 int result; |
102 const char* data; | 107 const char* data; |
103 int data_len; | 108 int data_len; |
104 | 109 |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 | 921 |
917 extern const char kSOCKS5GreetResponse[]; | 922 extern const char kSOCKS5GreetResponse[]; |
918 extern const int kSOCKS5GreetResponseLength; | 923 extern const int kSOCKS5GreetResponseLength; |
919 | 924 |
920 extern const char kSOCKS5OkRequest[]; | 925 extern const char kSOCKS5OkRequest[]; |
921 extern const int kSOCKS5OkRequestLength; | 926 extern const int kSOCKS5OkRequestLength; |
922 | 927 |
923 extern const char kSOCKS5OkResponse[]; | 928 extern const char kSOCKS5OkResponse[]; |
924 extern const int kSOCKS5OkResponseLength; | 929 extern const int kSOCKS5OkResponseLength; |
925 | 930 |
926 class MockSSLClientSocketPool : public SSLClientSocketPool { | |
927 public: | |
928 class MockConnectJob { | |
929 public: | |
930 MockConnectJob(ClientSocket* socket, ClientSocketHandle* handle, | |
931 CompletionCallback* callback); | |
932 | |
933 int Connect(); | |
934 bool CancelHandle(const ClientSocketHandle* handle); | |
935 | |
936 private: | |
937 void OnConnect(int rv); | |
938 | |
939 scoped_ptr<ClientSocket> socket_; | |
940 ClientSocketHandle* handle_; | |
941 CompletionCallback* user_callback_; | |
942 CompletionCallbackImpl<MockConnectJob> connect_callback_; | |
943 | |
944 DISALLOW_COPY_AND_ASSIGN(MockConnectJob); | |
945 }; | |
946 | |
947 MockSSLClientSocketPool( | |
948 int max_sockets, | |
949 int max_sockets_per_group, | |
950 ClientSocketPoolHistograms* histograms, | |
951 ClientSocketFactory* socket_factory, | |
952 TCPClientSocketPool* tcp_pool); | |
953 | |
954 virtual ~MockSSLClientSocketPool(); | |
955 | |
956 int release_count() const { return release_count_; } | |
957 int cancel_count() const { return cancel_count_; } | |
958 | |
959 // SSLClientSocketPool methods. | |
960 virtual int RequestSocket(const std::string& group_name, | |
961 const void* socket_params, | |
962 RequestPriority priority, | |
963 ClientSocketHandle* handle, | |
964 CompletionCallback* callback, | |
965 const BoundNetLog& net_log); | |
966 | |
967 virtual void CancelRequest(const std::string& group_name, | |
968 ClientSocketHandle* handle); | |
969 virtual void ReleaseSocket(const std::string& group_name, | |
970 ClientSocket* socket, int id); | |
971 | |
972 private: | |
973 ClientSocketFactory* client_socket_factory_; | |
974 int release_count_; | |
975 int cancel_count_; | |
976 ScopedVector<MockConnectJob> job_list_; | |
977 | |
978 DISALLOW_COPY_AND_ASSIGN(MockSSLClientSocketPool); | |
979 }; | |
980 | |
981 | |
982 } // namespace net | 931 } // namespace net |
983 | 932 |
984 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 933 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |