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

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

Issue 1123383004: Revert of Add AllReadDataConsumed and AllWriteDataConsumed methods to SocketDataProvider (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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 virtual ~SocketDataProvider() {} 192 virtual ~SocketDataProvider() {}
193 193
194 // Returns the buffer and result code for the next simulated read. 194 // Returns the buffer and result code for the next simulated read.
195 // If the |MockRead.result| is ERR_IO_PENDING, it informs the caller 195 // If the |MockRead.result| is ERR_IO_PENDING, it informs the caller
196 // that it will be called via the AsyncSocket::OnReadComplete() 196 // that it will be called via the AsyncSocket::OnReadComplete()
197 // function at a later time. 197 // function at a later time.
198 virtual MockRead OnRead() = 0; 198 virtual MockRead OnRead() = 0;
199 virtual MockWriteResult OnWrite(const std::string& data) = 0; 199 virtual MockWriteResult OnWrite(const std::string& data) = 0;
200 virtual void Reset() = 0; 200 virtual void Reset() = 0;
201 virtual bool AllReadDataConsumed() const = 0;
202 virtual bool AllWriteDataConsumed() const = 0;
203 201
204 // Accessor for the socket which is using the SocketDataProvider. 202 // Accessor for the socket which is using the SocketDataProvider.
205 AsyncSocket* socket() { return socket_; } 203 AsyncSocket* socket() { return socket_; }
206 void set_socket(AsyncSocket* socket) { socket_ = socket; } 204 void set_socket(AsyncSocket* socket) { socket_ = socket; }
207 205
208 MockConnect connect_data() const { return connect_; } 206 MockConnect connect_data() const { return connect_; }
209 void set_connect_data(const MockConnect& connect) { connect_ = connect; } 207 void set_connect_data(const MockConnect& connect) { connect_ = connect; }
210 208
211 private: 209 private:
212 MockConnect connect_; 210 MockConnect connect_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 MockWrite* writes, 287 MockWrite* writes,
290 size_t writes_count); 288 size_t writes_count);
291 ~StaticSocketDataProvider() override; 289 ~StaticSocketDataProvider() override;
292 290
293 virtual void CompleteRead() {} 291 virtual void CompleteRead() {}
294 292
295 // SocketDataProvider implementation. 293 // SocketDataProvider implementation.
296 MockRead OnRead() override; 294 MockRead OnRead() override;
297 MockWriteResult OnWrite(const std::string& data) override; 295 MockWriteResult OnWrite(const std::string& data) override;
298 void Reset() override; 296 void Reset() override;
299 bool AllReadDataConsumed() const override;
300 bool AllWriteDataConsumed() const override;
301 297
302 size_t read_index() const { return helper_.read_index(); } 298 size_t read_index() const { return helper_.read_index(); }
303 size_t write_index() const { return helper_.write_index(); } 299 size_t write_index() const { return helper_.write_index(); }
304 size_t read_count() const { return helper_.read_count(); } 300 size_t read_count() const { return helper_.read_count(); }
305 size_t write_count() const { return helper_.write_count(); } 301 size_t write_count() const { return helper_.write_count(); }
306 302
307 bool at_read_eof() const { return helper_.at_read_eof(); } 303 bool at_read_eof() const { return helper_.at_read_eof(); }
308 bool at_write_eof() const { return helper_.at_write_eof(); } 304 bool at_write_eof() const { return helper_.at_write_eof(); }
309 305
310 protected: 306 protected:
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 size_t reads_count, 492 size_t reads_count,
497 MockWrite* writes, 493 MockWrite* writes,
498 size_t writes_count); 494 size_t writes_count);
499 495
500 ~SequencedSocketData() override; 496 ~SequencedSocketData() override;
501 497
502 // SocketDataProviderBase implementation. 498 // SocketDataProviderBase implementation.
503 MockRead OnRead() override; 499 MockRead OnRead() override;
504 MockWriteResult OnWrite(const std::string& data) override; 500 MockWriteResult OnWrite(const std::string& data) override;
505 void Reset() override; 501 void Reset() override;
506 bool AllReadDataConsumed() const override; 502
507 bool AllWriteDataConsumed() const override; 503 // Returns true if all data has been read.
504 bool at_read_eof() const;
505
506 // Returns true if all data has been written.
507 bool at_write_eof() const;
508 508
509 private: 509 private:
510 // Defines the state for the read or write path. 510 // Defines the state for the read or write path.
511 enum IoState { 511 enum IoState {
512 IDLE, // No async operation is in progress. 512 IDLE, // No async operation is in progress.
513 PENDING, // An async operation in waiting for another opteration to 513 PENDING, // An async operation in waiting for another opteration to
514 // complete. 514 // complete.
515 COMPLETING, // A task has been posted to complet an async operation. 515 COMPLETING, // A task has been posted to complet an async operation.
516 }; 516 };
517 void OnReadComplete(); 517 void OnReadComplete();
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 1378
1379 extern const char kSOCKS5OkRequest[]; 1379 extern const char kSOCKS5OkRequest[];
1380 extern const int kSOCKS5OkRequestLength; 1380 extern const int kSOCKS5OkRequestLength;
1381 1381
1382 extern const char kSOCKS5OkResponse[]; 1382 extern const char kSOCKS5OkResponse[];
1383 extern const int kSOCKS5OkResponseLength; 1383 extern const int kSOCKS5OkResponseLength;
1384 1384
1385 } // namespace net 1385 } // namespace net
1386 1386
1387 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ 1387 #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