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