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

Unified Diff: net/socket/socket_test_util.cc

Issue 1494813002: Fix HttpStreamParser::CanReuseConnection(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring back removed test Created 5 years 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
« net/socket/socket_test_util.h ('K') | « net/socket/socket_test_util.h ('k') | no next file » | 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 93fcf3d7bd053489980ab129072216a3893c9d96..bd3bdedbe136fdd684f563e2449ffbc89d2e519d 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -143,6 +143,10 @@ MockConnect::MockConnect(IoMode io_mode, int r, IPEndPoint addr) :
MockConnect::~MockConnect() {}
+bool SocketDataProvider::IsIdle() const {
+ return true;
+}
+
StaticSocketDataHelper::StaticSocketDataHelper(MockRead* reads,
size_t reads_count,
MockWrite* writes,
@@ -288,6 +292,7 @@ SequencedSocketData::SequencedSocketData(MockRead* reads,
sequence_number_(0),
read_state_(IDLE),
write_state_(IDLE),
+ busy_before_sync_reads_(false),
weak_factory_(this) {
// Check that reads and writes have a contiguous set of sequence numbers
// starting from 0 and working their way up, with no repeats and skipping
@@ -427,6 +432,20 @@ bool SequencedSocketData::AllWriteDataConsumed() const {
return helper_.AllWriteDataConsumed();
}
+bool SequencedSocketData::IsIdle() const {
+ // If |busy_before_sync_reads_| is not set, always considered idle. If
+ // no reads left, or the next operation is a write, also consider it idle.
+ if (!busy_before_sync_reads_ || helper_.AllReadDataConsumed() ||
+ helper_.PeekRead().sequence_number != sequence_number_) {
+ return true;
+ }
+
+ // If the next operation is synchronous read, treat the socket as not idle.
+ if (helper_.PeekRead().mode == SYNCHRONOUS)
+ return false;
+ return true;
+}
+
bool SequencedSocketData::IsReadPaused() {
return read_state_ == PAUSED;
}
@@ -1059,7 +1078,7 @@ bool MockTCPClientSocket::IsConnected() const {
}
bool MockTCPClientSocket::IsConnectedAndIdle() const {
- return IsConnected();
+ return IsConnected() && data_->IsIdle();
}
int MockTCPClientSocket::GetPeerAddress(IPEndPoint* address) const {
@@ -1503,6 +1522,10 @@ bool MockSSLClientSocket::IsConnected() const {
return transport_->socket()->IsConnected();
}
+bool MockSSLClientSocket::IsConnectedAndIdle() const {
+ return transport_->socket()->IsConnectedAndIdle();
+}
+
bool MockSSLClientSocket::WasEverUsed() const {
return transport_->socket()->WasEverUsed();
}
« net/socket/socket_test_util.h ('K') | « net/socket/socket_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698