Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index b6e4a6931062d6afe6ccb7e530eed381172916fa..d7327d3ab1a18c929402b5b9eb03b76f09361b1a 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -740,7 +740,6 @@ 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)), |
stream_hi_water_mark_(kFirstStreamId), |
last_accepted_push_stream_id_(0), |
unclaimed_pushed_streams_(this), |
@@ -1378,8 +1377,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_) + |
@@ -1869,19 +1869,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) |
+ read_buffer_ = nullptr; |
davidben
2017/03/07 22:53:21
This could be moved into the line 1895 check, righ
xunjieli
2017/03/07 23:09:30
No, in the case of a normal Read(), we can only re
davidben
2017/03/07 23:12:37
Right, but normal Read doesn't hit that code. A no
xunjieli
2017/03/07 23:39:53
Done. Oops.. You are right. I can't believe I mis
|
} |
if (rv == ERR_READ_IF_READY_NOT_IMPLEMENTED) { |
// Fallback to regular Read(). |
@@ -1896,6 +1898,7 @@ int SpdySession::DoRead() { |
} |
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 |
@@ -1933,6 +1936,7 @@ int SpdySession::DoReadComplete(int result) { |
SpdyFramer::SPDY_NO_ERROR); |
} |
+ read_buffer_ = nullptr; |
read_state_ = READ_STATE_DO_READ; |
return OK; |
} |