| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 size_t write_count() const { return write_count_; } | 224 size_t write_count() const { return write_count_; } |
| 225 | 225 |
| 226 bool at_read_eof() const { return read_index_ >= read_count_; } | 226 bool at_read_eof() const { return read_index_ >= read_count_; } |
| 227 bool at_write_eof() const { return write_index_ >= write_count_; } | 227 bool at_write_eof() const { return write_index_ >= write_count_; } |
| 228 | 228 |
| 229 virtual void CompleteRead() {} | 229 virtual void CompleteRead() {} |
| 230 | 230 |
| 231 // SocketDataProvider implementation. | 231 // SocketDataProvider implementation. |
| 232 virtual MockRead GetNextRead() OVERRIDE; | 232 virtual MockRead GetNextRead() OVERRIDE; |
| 233 virtual MockWriteResult OnWrite(const std::string& data) OVERRIDE; | 233 virtual MockWriteResult OnWrite(const std::string& data) OVERRIDE; |
| 234 ; virtual void Reset() OVERRIDE; | 234 virtual void Reset() OVERRIDE; |
| 235 | 235 |
| 236 private: | 236 private: |
| 237 MockRead* reads_; | 237 MockRead* reads_; |
| 238 size_t read_index_; | 238 size_t read_index_; |
| 239 size_t read_count_; | 239 size_t read_count_; |
| 240 MockWrite* writes_; | 240 MockWrite* writes_; |
| 241 size_t write_index_; | 241 size_t write_index_; |
| 242 size_t write_count_; | 242 size_t write_count_; |
| 243 | 243 |
| 244 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataProvider); | 244 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataProvider); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 int read_offset_; | 709 int read_offset_; |
| 710 MockRead read_data_; | 710 MockRead read_data_; |
| 711 bool need_read_data_; | 711 bool need_read_data_; |
| 712 | 712 |
| 713 // True if the peer has closed the connection. This allows us to simulate | 713 // True if the peer has closed the connection. This allows us to simulate |
| 714 // the recv(..., MSG_PEEK) call in the IsConnectedAndIdle method of the real | 714 // the recv(..., MSG_PEEK) call in the IsConnectedAndIdle method of the real |
| 715 // TCPClientSocket. | 715 // TCPClientSocket. |
| 716 bool peer_closed_connection_; | 716 bool peer_closed_connection_; |
| 717 | 717 |
| 718 // While an asynchronous IO is pending, we save our user-buffer state. | 718 // While an asynchronous IO is pending, we save our user-buffer state. |
| 719 IOBuffer* pending_buf_; | 719 scoped_refptr<IOBuffer> pending_buf_; |
| 720 int pending_buf_len_; | 720 int pending_buf_len_; |
| 721 CompletionCallback pending_callback_; | 721 CompletionCallback pending_callback_; |
| 722 bool was_used_to_convey_data_; | 722 bool was_used_to_convey_data_; |
| 723 }; | 723 }; |
| 724 | 724 |
| 725 // DeterministicSocketHelper is a helper class that can be used | 725 // DeterministicSocketHelper is a helper class that can be used |
| 726 // to simulate net::Socket::Read() and net::Socket::Write() | 726 // to simulate net::Socket::Read() and net::Socket::Write() |
| 727 // using deterministic |data|. | 727 // using deterministic |data|. |
| 728 // Note: This is provided as a common helper class because | 728 // Note: This is provided as a common helper class because |
| 729 // of the inheritance hierarchy of DeterministicMock[UDP,TCP]ClientSocket and a | 729 // of the inheritance hierarchy of DeterministicMock[UDP,TCP]ClientSocket and a |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 bool connected_; | 948 bool connected_; |
| 949 SocketDataProvider* data_; | 949 SocketDataProvider* data_; |
| 950 int read_offset_; | 950 int read_offset_; |
| 951 MockRead read_data_; | 951 MockRead read_data_; |
| 952 bool need_read_data_; | 952 bool need_read_data_; |
| 953 | 953 |
| 954 // Address of the "remote" peer we're connected to. | 954 // Address of the "remote" peer we're connected to. |
| 955 IPEndPoint peer_addr_; | 955 IPEndPoint peer_addr_; |
| 956 | 956 |
| 957 // While an asynchronous IO is pending, we save our user-buffer state. | 957 // While an asynchronous IO is pending, we save our user-buffer state. |
| 958 IOBuffer* pending_buf_; | 958 scoped_refptr<IOBuffer> pending_buf_; |
| 959 int pending_buf_len_; | 959 int pending_buf_len_; |
| 960 CompletionCallback pending_callback_; | 960 CompletionCallback pending_callback_; |
| 961 | 961 |
| 962 BoundNetLog net_log_; | 962 BoundNetLog net_log_; |
| 963 | 963 |
| 964 base::WeakPtrFactory<MockUDPClientSocket> weak_factory_; | 964 base::WeakPtrFactory<MockUDPClientSocket> weak_factory_; |
| 965 | 965 |
| 966 DISALLOW_COPY_AND_ASSIGN(MockUDPClientSocket); | 966 DISALLOW_COPY_AND_ASSIGN(MockUDPClientSocket); |
| 967 }; | 967 }; |
| 968 | 968 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1204 |
| 1205 extern const char kSOCKS5OkRequest[]; | 1205 extern const char kSOCKS5OkRequest[]; |
| 1206 extern const int kSOCKS5OkRequestLength; | 1206 extern const int kSOCKS5OkRequestLength; |
| 1207 | 1207 |
| 1208 extern const char kSOCKS5OkResponse[]; | 1208 extern const char kSOCKS5OkResponse[]; |
| 1209 extern const int kSOCKS5OkResponseLength; | 1209 extern const int kSOCKS5OkResponseLength; |
| 1210 | 1210 |
| 1211 } // namespace net | 1211 } // namespace net |
| 1212 | 1212 |
| 1213 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 1213 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
| OLD | NEW |