Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: net/socket/socket_test_util.h

Issue 1123393005: Remove redundant at_read_eof and at_write_eof methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/sequenced_socket_data_unittest.cc ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Returns true if |data| is valid data for the next write. In order 258 // Returns true if |data| is valid data for the next write. In order
259 // to support short writes, the next write may be longer than |data| 259 // to support short writes, the next write may be longer than |data|
260 // in which case this method will still return true. 260 // in which case this method will still return true.
261 bool VerifyWriteData(const std::string& data); 261 bool VerifyWriteData(const std::string& data);
262 262
263 size_t read_index() const { return read_index_; } 263 size_t read_index() const { return read_index_; }
264 size_t write_index() const { return write_index_; } 264 size_t write_index() const { return write_index_; }
265 size_t read_count() const { return read_count_; } 265 size_t read_count() const { return read_count_; }
266 size_t write_count() const { return write_count_; } 266 size_t write_count() const { return write_count_; }
267 267
268 bool at_read_eof() const { return read_index_ >= read_count_; } 268 bool AllReadDataConsumed() const { return read_index_ >= read_count_; }
269 bool at_write_eof() const { return write_index_ >= write_count_; } 269 bool AllWriteDataConsumed() const { return write_index_ >= write_count_; }
270 270
271 private: 271 private:
272 MockRead* reads_; 272 MockRead* reads_;
273 size_t read_index_; 273 size_t read_index_;
274 size_t read_count_; 274 size_t read_count_;
275 MockWrite* writes_; 275 MockWrite* writes_;
276 size_t write_index_; 276 size_t write_index_;
277 size_t write_count_; 277 size_t write_count_;
278 278
279 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataHelper); 279 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataHelper);
(...skipping 17 matching lines...) Expand all
297 MockWriteResult OnWrite(const std::string& data) override; 297 MockWriteResult OnWrite(const std::string& data) override;
298 void Reset() override; 298 void Reset() override;
299 bool AllReadDataConsumed() const override; 299 bool AllReadDataConsumed() const override;
300 bool AllWriteDataConsumed() const override; 300 bool AllWriteDataConsumed() const override;
301 301
302 size_t read_index() const { return helper_.read_index(); } 302 size_t read_index() const { return helper_.read_index(); }
303 size_t write_index() const { return helper_.write_index(); } 303 size_t write_index() const { return helper_.write_index(); }
304 size_t read_count() const { return helper_.read_count(); } 304 size_t read_count() const { return helper_.read_count(); }
305 size_t write_count() const { return helper_.write_count(); } 305 size_t write_count() const { return helper_.write_count(); }
306 306
307 bool at_read_eof() const { return helper_.at_read_eof(); }
308 bool at_write_eof() const { return helper_.at_write_eof(); }
309
310 protected: 307 protected:
311 StaticSocketDataHelper* helper() { return &helper_; } 308 StaticSocketDataHelper* helper() { return &helper_; }
312 309
313 private: 310 private:
314 StaticSocketDataHelper helper_; 311 StaticSocketDataHelper helper_;
315 312
316 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataProvider); 313 DISALLOW_COPY_AND_ASSIGN(StaticSocketDataProvider);
317 }; 314 };
318 315
319 // SocketDataProvider which can make decisions about next mock reads based on 316 // SocketDataProvider which can make decisions about next mock reads based on
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 393
397 ~SequencedSocketData() override; 394 ~SequencedSocketData() override;
398 395
399 // SocketDataProviderBase implementation. 396 // SocketDataProviderBase implementation.
400 MockRead OnRead() override; 397 MockRead OnRead() override;
401 MockWriteResult OnWrite(const std::string& data) override; 398 MockWriteResult OnWrite(const std::string& data) override;
402 void Reset() override; 399 void Reset() override;
403 bool AllReadDataConsumed() const override; 400 bool AllReadDataConsumed() const override;
404 bool AllWriteDataConsumed() const override; 401 bool AllWriteDataConsumed() const override;
405 402
406 // Returns true if all data has been read.
407 bool at_read_eof() const;
408
409 // Returns true if all data has been written.
410 bool at_write_eof() const;
411
412 bool IsReadPaused(); 403 bool IsReadPaused();
413 void CompleteRead(); 404 void CompleteRead();
414 405
415 private: 406 private:
416 // Defines the state for the read or write path. 407 // Defines the state for the read or write path.
417 enum IoState { 408 enum IoState {
418 IDLE, // No async operation is in progress. 409 IDLE, // No async operation is in progress.
419 PENDING, // An async operation in waiting for another opteration to 410 PENDING, // An async operation in waiting for another opteration to
420 // complete. 411 // complete.
421 COMPLETING, // A task has been posted to complet an async operation. 412 COMPLETING, // A task has been posted to complet an async operation.
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1284
1294 extern const char kSOCKS5OkRequest[]; 1285 extern const char kSOCKS5OkRequest[];
1295 extern const int kSOCKS5OkRequestLength; 1286 extern const int kSOCKS5OkRequestLength;
1296 1287
1297 extern const char kSOCKS5OkResponse[]; 1288 extern const char kSOCKS5OkResponse[];
1298 extern const int kSOCKS5OkResponseLength; 1289 extern const int kSOCKS5OkResponseLength;
1299 1290
1300 } // namespace net 1291 } // namespace net
1301 1292
1302 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ 1293 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/socket/sequenced_socket_data_unittest.cc ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698