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

Unified Diff: net/socket/socket_test_util.cc

Issue 13834009: SPDY - Re-land greedy read support for SpdySession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverting the Revert of 181390 and disabled the tests in patch 1 Created 7 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
Index: net/socket/socket_test_util.cc
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index da0bf5db428bc05575b4042d380a95723cae0dbc..dea68d2b18a6185f87db1f2f5fa9ef8349fefacb 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -724,6 +724,8 @@ bool MockClientSocket::IsConnectedAndIdle() const {
}
int MockClientSocket::GetPeerAddress(IPEndPoint* address) const {
+ if (!IsConnected())
+ return ERR_SOCKET_NOT_CONNECTED;
*address = peer_addr_;
return OK;
}
@@ -820,6 +822,11 @@ int MockTCPClientSocket::Read(IOBuffer* buf, int buf_len,
if (need_read_data_) {
read_data_ = data_->GetNextRead();
+ if (read_data_.result == ERR_CONNECTION_CLOSED) {
+ // This MockRead is just a marker to instruct us to set
+ // peer_closed_connection_.
+ peer_closed_connection_ = true;
+ }
if (read_data_.result == ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ) {
// This MockRead is just a marker to instruct us to set
// peer_closed_connection_. Skip it and get the next one.
@@ -978,7 +985,8 @@ DeterministicMockTCPClientSocket::DeterministicMockTCPClientSocket(
read_buf_len_(0),
read_pending_(false),
data_(data),
- was_used_to_convey_data_(false) {
+ was_used_to_convey_data_(false),
+ peer_closed_connection_(false) {
peer_addr_ = data->connect_data().peer_addr;
}
@@ -1052,6 +1060,12 @@ int DeterministicMockTCPClientSocket::Read(
// use small buffers, split the data into multiple MockReads.
DCHECK_LE(read_data_.data_len, buf_len);
+ if (read_data_.result == ERR_CONNECTION_CLOSED) {
+ // This MockRead is just a marker to instruct us to set
+ // peer_closed_connection_.
+ peer_closed_connection_ = true;
+ }
+
read_buf_ = buf;
read_buf_len_ = buf_len;
read_callback_ = callback;
@@ -1084,7 +1098,7 @@ void DeterministicMockTCPClientSocket::Disconnect() {
}
bool DeterministicMockTCPClientSocket::IsConnected() const {
- return connected_;
+ return connected_ && !peer_closed_connection_;
}
bool DeterministicMockTCPClientSocket::IsConnectedAndIdle() const {

Powered by Google App Engine
This is Rietveld 408576698