Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index 79257d7795f2247d66cea021942970f24158d888..4cd6bd2b5f3746f3ce250dc0ac5152fe3f335710 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -737,7 +737,7 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, |
pool_(NULL), |
http_server_properties_(http_server_properties), |
transport_security_state_(transport_security_state), |
- read_buffer_(new IOBuffer(kReadBufferSize)), |
+ // read_buffer_(new IOBuffer(kReadBufferSize)), |
stream_hi_water_mark_(kFirstStreamId), |
last_accepted_push_stream_id_(0), |
unclaimed_pushed_streams_(this), |
@@ -1369,8 +1369,9 @@ size_t SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats, |
connection_->DumpMemoryStats(stats); |
// |connection_| is estimated in stats->total_size. |read_buffer_| is |
- // estimated in kReadBufferSize. TODO(xunjieli): Make them use EMU(). |
- return stats->total_size + kReadBufferSize + |
+ // estimated in |read_buffer_size|. TODO(xunjieli): Make them use EMU(). |
+ size_t read_buffer_size = read_buffer_ ? kReadBufferSize : 0; |
+ return stats->total_size + read_buffer_size + |
SpdyEstimateMemoryUsage(spdy_session_key_) + |
SpdyEstimateMemoryUsage(pooled_aliases_) + |
SpdyEstimateMemoryUsage(active_streams_) + |
@@ -1860,19 +1861,21 @@ int SpdySession::DoReadLoop(ReadState expected_read_state, int result) { |
} |
int SpdySession::DoRead() { |
+ DCHECK(!read_buffer_); |
CHECK(in_io_loop_); |
CHECK(connection_); |
CHECK(connection_->socket()); |
read_state_ = READ_STATE_DO_READ_COMPLETE; |
int rv = ERR_READ_IF_READY_NOT_IMPLEMENTED; |
+ read_buffer_ = new IOBuffer(kReadBufferSize); |
if (base::FeatureList::IsEnabled(Socket::kReadIfReadyExperiment)) { |
rv = connection_->socket()->ReadIfReady( |
read_buffer_.get(), kReadBufferSize, |
base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), |
READ_STATE_DO_READ)); |
- // TODO(xunjieli): Follow-up CL to release |read_buffer_|. |
- // https://crbug.com/690915. |
+ if (rv == ERR_IO_PENDING) |
DmitrySkiba
2017/03/06 21:42:37
Are we killing buffer with read operation in progr
xunjieli
2017/03/06 21:58:59
Great question. The new ReadIfReady() method that
xunjieli
2017/03/06 22:00:51
Btw, if you apply the CL linked above and start Ch
|
+ read_buffer_ = nullptr; |
} |
if (rv == ERR_READ_IF_READY_NOT_IMPLEMENTED) { |
// Fallback to regular Read(). |
@@ -1881,12 +1884,15 @@ int SpdySession::DoRead() { |
base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), |
READ_STATE_DO_READ_COMPLETE)); |
} |
- if (rv == ERR_IO_PENDING) |
+ if (rv == ERR_IO_PENDING) { |
read_state_ = READ_STATE_DO_READ; |
+ return ERR_IO_PENDING; |
+ } |
return rv; |
} |
int SpdySession::DoReadComplete(int result) { |
+ DCHECK(read_buffer_); |
CHECK(in_io_loop_); |
// Parse a frame. For now this code requires that the frame fit into our |
@@ -1924,6 +1930,7 @@ int SpdySession::DoReadComplete(int result) { |
SpdyFramer::SPDY_NO_ERROR); |
} |
+ read_buffer_ = nullptr; |
read_state_ = READ_STATE_DO_READ; |
return OK; |
} |