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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 std::string next_proto; | 326 std::string next_proto; |
327 NextProtoVector next_protos_expected_in_ssl_config; | 327 NextProtoVector next_protos_expected_in_ssl_config; |
328 bool client_cert_sent; | 328 bool client_cert_sent; |
329 SSLCertRequestInfo* cert_request_info; | 329 SSLCertRequestInfo* cert_request_info; |
330 scoped_refptr<X509Certificate> cert; | 330 scoped_refptr<X509Certificate> cert; |
331 bool channel_id_sent; | 331 bool channel_id_sent; |
332 ChannelIDService* channel_id_service; | 332 ChannelIDService* channel_id_service; |
333 int connection_status; | 333 int connection_status; |
334 }; | 334 }; |
335 | 335 |
336 // A DataProvider where the client must write a request before the reads (e.g. | |
337 // the response) will complete. | |
338 class DelayedSocketData : public StaticSocketDataProvider { | |
339 public: | |
340 // |write_delay| the number of MockWrites to complete before allowing | |
341 // a MockRead to complete. | |
342 // |reads| the list of MockRead completions. | |
343 // |writes| the list of MockWrite completions. | |
344 // Note: For stream sockets, the MockRead list must end with a EOF, e.g., a | |
345 // MockRead(true, 0, 0); | |
346 DelayedSocketData(int write_delay, | |
347 MockRead* reads, | |
348 size_t reads_count, | |
349 MockWrite* writes, | |
350 size_t writes_count); | |
351 | |
352 // |connect| the result for the connect phase. | |
353 // |reads| the list of MockRead completions. | |
354 // |write_delay| the number of MockWrites to complete before allowing | |
355 // a MockRead to complete. | |
356 // |writes| the list of MockWrite completions. | |
357 // Note: For stream sockets, the MockRead list must end with a EOF, e.g., a | |
358 // MockRead(true, 0, 0); | |
359 DelayedSocketData(const MockConnect& connect, | |
360 int write_delay, | |
361 MockRead* reads, | |
362 size_t reads_count, | |
363 MockWrite* writes, | |
364 size_t writes_count); | |
365 ~DelayedSocketData() override; | |
366 | |
367 void ForceNextRead(); | |
368 | |
369 // StaticSocketDataProvider: | |
370 MockRead OnRead() override; | |
371 MockWriteResult OnWrite(const std::string& data) override; | |
372 void Reset() override; | |
373 void CompleteRead() override; | |
374 | |
375 private: | |
376 int write_delay_; | |
377 bool read_in_progress_; | |
378 | |
379 base::WeakPtrFactory<DelayedSocketData> weak_factory_; | |
380 | |
381 DISALLOW_COPY_AND_ASSIGN(DelayedSocketData); | |
382 }; | |
383 | |
384 // Uses the sequence_number field in the mock reads and writes to | 336 // Uses the sequence_number field in the mock reads and writes to |
385 // complete the operations in a specified order. | 337 // complete the operations in a specified order. |
386 class SequencedSocketData : public SocketDataProvider { | 338 class SequencedSocketData : public SocketDataProvider { |
387 public: | 339 public: |
388 // |reads| is the list of MockRead completions. | 340 // |reads| is the list of MockRead completions. |
389 // |writes| is the list of MockWrite completions. | 341 // |writes| is the list of MockWrite completions. |
390 SequencedSocketData(MockRead* reads, | 342 SequencedSocketData(MockRead* reads, |
391 size_t reads_count, | 343 size_t reads_count, |
392 MockWrite* writes, | 344 MockWrite* writes, |
393 size_t writes_count); | 345 size_t writes_count); |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 | 1237 |
1286 extern const char kSOCKS5OkRequest[]; | 1238 extern const char kSOCKS5OkRequest[]; |
1287 extern const int kSOCKS5OkRequestLength; | 1239 extern const int kSOCKS5OkRequestLength; |
1288 | 1240 |
1289 extern const char kSOCKS5OkResponse[]; | 1241 extern const char kSOCKS5OkResponse[]; |
1290 extern const int kSOCKS5OkResponseLength; | 1242 extern const int kSOCKS5OkResponseLength; |
1291 | 1243 |
1292 } // namespace net | 1244 } // namespace net |
1293 | 1245 |
1294 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1246 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |