| Index: net/spdy/spdy_session.cc
|
| diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
|
| index b6e4a6931062d6afe6ccb7e530eed381172916fa..2b47a81262ca65cedea88509aa3ae99ddafb02f9 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,24 @@ 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;
|
| + read_state_ = READ_STATE_DO_READ;
|
| + return rv;
|
| + }
|
| }
|
| if (rv == ERR_READ_IF_READY_NOT_IMPLEMENTED) {
|
| // Fallback to regular Read().
|
| @@ -1890,12 +1895,11 @@ int SpdySession::DoRead() {
|
| base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(),
|
| READ_STATE_DO_READ_COMPLETE));
|
| }
|
| - if (rv == ERR_IO_PENDING)
|
| - read_state_ = READ_STATE_DO_READ;
|
| 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
|
| @@ -1933,6 +1937,7 @@ int SpdySession::DoReadComplete(int result) {
|
| SpdyFramer::SPDY_NO_ERROR);
|
| }
|
|
|
| + read_buffer_ = nullptr;
|
| read_state_ = READ_STATE_DO_READ;
|
| return OK;
|
| }
|
|
|