OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 void set_short_read_limit(int limit) { short_read_limit_ = limit; } | 125 void set_short_read_limit(int limit) { short_read_limit_ = limit; } |
126 | 126 |
127 protected: | 127 protected: |
128 // The next time there is a read from this socket, it will return |data|. | 128 // The next time there is a read from this socket, it will return |data|. |
129 // Before calling SimulateRead next time, the previous data must be consumed. | 129 // Before calling SimulateRead next time, the previous data must be consumed. |
130 void SimulateRead(const char* data); | 130 void SimulateRead(const char* data); |
131 | 131 |
132 private: | 132 private: |
133 MockRead read_; | 133 MockRead read_; |
134 bool has_read_; | 134 bool has_read_; |
135 bool consumed_read_; | |
136 | 135 |
137 // Max number of bytes we will read at a time. 0 means no limit. | 136 // Max number of bytes we will read at a time. 0 means no limit. |
138 int short_read_limit_; | 137 int short_read_limit_; |
139 | 138 |
140 DISALLOW_COPY_AND_ASSIGN(DynamicMockSocket); | 139 DISALLOW_COPY_AND_ASSIGN(DynamicMockSocket); |
141 }; | 140 }; |
142 | 141 |
143 // MockSSLSockets only need to keep track of the return code from calls to | 142 // MockSSLSockets only need to keep track of the return code from calls to |
144 // Connect(). | 143 // Connect(). |
145 struct MockSSLSocket { | 144 struct MockSSLSocket { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 private: | 280 private: |
282 class ConnectCallback; | 281 class ConnectCallback; |
283 | 282 |
284 scoped_ptr<ClientSocket> transport_; | 283 scoped_ptr<ClientSocket> transport_; |
285 net::MockSSLSocket* data_; | 284 net::MockSSLSocket* data_; |
286 }; | 285 }; |
287 | 286 |
288 } // namespace net | 287 } // namespace net |
289 | 288 |
290 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 289 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |