OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 net::CompletionCallback* callback); | 624 net::CompletionCallback* callback); |
625 | 625 |
626 // StreamSocket methods: | 626 // StreamSocket methods: |
627 virtual int Connect(net::CompletionCallback* callback); | 627 virtual int Connect(net::CompletionCallback* callback); |
628 virtual void Disconnect(); | 628 virtual void Disconnect(); |
629 virtual bool IsConnected() const; | 629 virtual bool IsConnected() const; |
630 virtual bool IsConnectedAndIdle() const; | 630 virtual bool IsConnectedAndIdle() const; |
631 virtual int GetPeerAddress(AddressList* address) const; | 631 virtual int GetPeerAddress(AddressList* address) const; |
632 virtual bool WasEverUsed() const; | 632 virtual bool WasEverUsed() const; |
633 virtual bool UsingTCPFastOpen() const; | 633 virtual bool UsingTCPFastOpen() const; |
| 634 virtual int64 NumBytesRead() const; |
| 635 virtual base::TimeDelta GetConnectTimeMicros() const; |
634 | 636 |
635 // MockClientSocket: | 637 // MockClientSocket: |
636 virtual void OnReadComplete(const MockRead& data); | 638 virtual void OnReadComplete(const MockRead& data); |
637 | 639 |
638 private: | 640 private: |
639 int CompleteRead(); | 641 int CompleteRead(); |
640 | 642 |
641 net::AddressList addresses_; | 643 net::AddressList addresses_; |
642 | 644 |
643 net::SocketDataProvider* data_; | 645 net::SocketDataProvider* data_; |
644 int read_offset_; | 646 int read_offset_; |
| 647 int num_bytes_read_; |
645 net::MockRead read_data_; | 648 net::MockRead read_data_; |
646 bool need_read_data_; | 649 bool need_read_data_; |
647 | 650 |
648 // True if the peer has closed the connection. This allows us to simulate | 651 // True if the peer has closed the connection. This allows us to simulate |
649 // the recv(..., MSG_PEEK) call in the IsConnectedAndIdle method of the real | 652 // the recv(..., MSG_PEEK) call in the IsConnectedAndIdle method of the real |
650 // TCPClientSocket. | 653 // TCPClientSocket. |
651 bool peer_closed_connection_; | 654 bool peer_closed_connection_; |
652 | 655 |
653 // While an asynchronous IO is pending, we save our user-buffer state. | 656 // While an asynchronous IO is pending, we save our user-buffer state. |
654 net::IOBuffer* pending_buf_; | 657 net::IOBuffer* pending_buf_; |
(...skipping 21 matching lines...) Expand all Loading... |
676 virtual int Read(net::IOBuffer* buf, int buf_len, | 679 virtual int Read(net::IOBuffer* buf, int buf_len, |
677 net::CompletionCallback* callback); | 680 net::CompletionCallback* callback); |
678 | 681 |
679 // StreamSocket: | 682 // StreamSocket: |
680 virtual int Connect(net::CompletionCallback* callback); | 683 virtual int Connect(net::CompletionCallback* callback); |
681 virtual void Disconnect(); | 684 virtual void Disconnect(); |
682 virtual bool IsConnected() const; | 685 virtual bool IsConnected() const; |
683 virtual bool IsConnectedAndIdle() const; | 686 virtual bool IsConnectedAndIdle() const; |
684 virtual bool WasEverUsed() const; | 687 virtual bool WasEverUsed() const; |
685 virtual bool UsingTCPFastOpen() const; | 688 virtual bool UsingTCPFastOpen() const; |
| 689 virtual int64 NumBytesRead() const; |
| 690 virtual base::TimeDelta GetConnectTimeMicros() const; |
686 | 691 |
687 // MockClientSocket: | 692 // MockClientSocket: |
688 virtual void OnReadComplete(const MockRead& data); | 693 virtual void OnReadComplete(const MockRead& data); |
689 | 694 |
690 private: | 695 private: |
691 bool write_pending_; | 696 bool write_pending_; |
692 net::CompletionCallback* write_callback_; | 697 net::CompletionCallback* write_callback_; |
693 int write_result_; | 698 int write_result_; |
694 | 699 |
695 net::MockRead read_data_; | 700 net::MockRead read_data_; |
(...skipping 21 matching lines...) Expand all Loading... |
717 net::CompletionCallback* callback); | 722 net::CompletionCallback* callback); |
718 virtual int Write(net::IOBuffer* buf, int buf_len, | 723 virtual int Write(net::IOBuffer* buf, int buf_len, |
719 net::CompletionCallback* callback); | 724 net::CompletionCallback* callback); |
720 | 725 |
721 // StreamSocket methods: | 726 // StreamSocket methods: |
722 virtual int Connect(net::CompletionCallback* callback); | 727 virtual int Connect(net::CompletionCallback* callback); |
723 virtual void Disconnect(); | 728 virtual void Disconnect(); |
724 virtual bool IsConnected() const; | 729 virtual bool IsConnected() const; |
725 virtual bool WasEverUsed() const; | 730 virtual bool WasEverUsed() const; |
726 virtual bool UsingTCPFastOpen() const; | 731 virtual bool UsingTCPFastOpen() const; |
| 732 virtual int64 NumBytesRead() const; |
| 733 virtual base::TimeDelta GetConnectTimeMicros() const; |
727 | 734 |
728 // SSLClientSocket methods: | 735 // SSLClientSocket methods: |
729 virtual void GetSSLInfo(net::SSLInfo* ssl_info); | 736 virtual void GetSSLInfo(net::SSLInfo* ssl_info); |
730 virtual void GetSSLCertRequestInfo( | 737 virtual void GetSSLCertRequestInfo( |
731 net::SSLCertRequestInfo* cert_request_info); | 738 net::SSLCertRequestInfo* cert_request_info); |
732 virtual NextProtoStatus GetNextProto(std::string* proto); | 739 virtual NextProtoStatus GetNextProto(std::string* proto); |
733 virtual bool was_npn_negotiated() const; | 740 virtual bool was_npn_negotiated() const; |
734 virtual bool set_was_npn_negotiated(bool negotiated); | 741 virtual bool set_was_npn_negotiated(bool negotiated); |
735 | 742 |
736 // This MockSocket does not implement the manual async IO feature. | 743 // This MockSocket does not implement the manual async IO feature. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 999 |
993 extern const char kSOCKS5OkRequest[]; | 1000 extern const char kSOCKS5OkRequest[]; |
994 extern const int kSOCKS5OkRequestLength; | 1001 extern const int kSOCKS5OkRequestLength; |
995 | 1002 |
996 extern const char kSOCKS5OkResponse[]; | 1003 extern const char kSOCKS5OkResponse[]; |
997 extern const int kSOCKS5OkResponseLength; | 1004 extern const int kSOCKS5OkResponseLength; |
998 | 1005 |
999 } // namespace net | 1006 } // namespace net |
1000 | 1007 |
1001 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1008 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |