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

Unified Diff: net/socket/socket_test_util.cc

Issue 1129473002: Revert of Add CompleteRead to SequencedSocketData and convert all but 3 tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.cc
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 20983aec00dcded9e6b009dc80261342db6cb444..4df69d2fa1ccfe46bed35f6bf2e6e54d87fe2f47 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -531,6 +531,15 @@
NET_TRACE(1, " *** ") << "next_read: " << next_read.sequence_number;
CHECK_GE(next_read.sequence_number, sequence_number_);
+ // Special case handling for hanging reads.
+ if (next_read.mode == ASYNC && next_read.result == ERR_IO_PENDING) {
+ NET_TRACE(1, " *** ") << "Hanging read";
+ helper_.AdvanceRead();
+ ++sequence_number_;
+ CHECK(helper_.AllReadDataConsumed());
+ return MockRead(SYNCHRONOUS, ERR_IO_PENDING);
+ }
+
if (next_read.sequence_number <= sequence_number_) {
if (next_read.mode == SYNCHRONOUS) {
NET_TRACE(1, " *** ") << "Returning synchronously";
@@ -541,15 +550,6 @@
return next_read;
}
- // If the result is ERR_IO_PENDING, then advance to the next state
- // and pause reads.
- if (next_read.result == ERR_IO_PENDING) {
- NET_TRACE(1, " *** ") << "Pausing at: " << sequence_number_;
- ++sequence_number_;
- helper_.AdvanceRead();
- read_state_ = PAUSED;
- return MockRead(SYNCHRONOUS, ERR_IO_PENDING);
- }
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&SequencedSocketData::OnReadComplete,
weak_factory_.GetWeakPtr()));
@@ -624,19 +624,6 @@
return helper_.AllWriteDataConsumed();
}
-bool SequencedSocketData::IsReadPaused() {
- return read_state_ == PAUSED;
-}
-
-void SequencedSocketData::CompleteRead() {
- if (read_state_ != PAUSED) {
- ADD_FAILURE() << "Unable to CompleteRead when not paused.";
- return;
- }
- read_state_ = COMPLETING;
- OnReadComplete();
-}
-
void SequencedSocketData::MaybePostReadCompleteTask() {
NET_TRACE(1, " ****** ") << " current: " << sequence_number_;
// Only trigger the next read to complete if there is already a read pending
@@ -646,16 +633,6 @@
return;
}
- // If the result is ERR_IO_PENDING, then advance to the next state
- // and pause reads.
- if (helper_.PeekRead().result == ERR_IO_PENDING) {
- NET_TRACE(1, " *** ") << "Pausing read at: " << sequence_number_;
- ++sequence_number_;
- helper_.AdvanceRead();
- read_state_ = PAUSED;
- return;
- }
-
NET_TRACE(1, " ****** ") << "Posting task to complete read: "
<< sequence_number_;
base::MessageLoop::current()->PostTask(
@@ -703,8 +680,7 @@
// before calling that.
MaybePostWriteCompleteTask();
- NET_TRACE(1, " *** ") << "Completing socket read for: "
- << data.sequence_number;
+ NET_TRACE(1, " *** ") << "Completing socket read for: " << sequence_number_;
DumpMockReadWrite(data);
socket()->OnReadComplete(data);
NET_TRACE(1, " *** ") << "Done";
@@ -731,8 +707,7 @@
// before calling that.
MaybePostReadCompleteTask();
- NET_TRACE(1, " *** ") << " Completing socket write for: "
- << data.sequence_number;
+ NET_TRACE(1, " *** ") << " Completing socket write for: " << sequence_number_;
socket()->OnWriteComplete(rv);
NET_TRACE(1, " *** ") << "Done";
}
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698