Chromium Code Reviews| Index: net/spdy/spdy_session.cc |
| diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
| index 55c0c47d393baf5d29736df0831b5853ce296a81..98507717b53c76f559d421b9a25f7ae5fa783a48 100644 |
| --- a/net/spdy/spdy_session.cc |
| +++ b/net/spdy/spdy_session.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/metrics/sparse_histogram.h" |
| #include "base/profiler/scoped_tracker.h" |
| @@ -45,6 +46,7 @@ |
| #include "net/log/net_log_source_type.h" |
| #include "net/log/net_log_with_source.h" |
| #include "net/proxy/proxy_server.h" |
| +#include "net/socket/socket.h" |
| #include "net/socket/ssl_client_socket.h" |
| #include "net/spdy/spdy_buffer_producer.h" |
| #include "net/spdy/spdy_frame_builder.h" |
| @@ -1441,11 +1443,25 @@ int SpdySession::DoRead() { |
| CHECK(connection_); |
| CHECK(connection_->socket()); |
| read_state_ = READ_STATE_DO_READ_COMPLETE; |
| - return connection_->socket()->Read( |
| - read_buffer_.get(), |
| - kReadBufferSize, |
| - base::Bind(&SpdySession::PumpReadLoop, |
| - weak_factory_.GetWeakPtr(), READ_STATE_DO_READ_COMPLETE)); |
| + int rv = ERR_READ_IF_READY_NOT_IMPLEMENTED; |
| + if (base::FieldTrialList::FindFullName(Socket::kReadIfReadyTrialName) == |
| + "enable") { |
| + rv = connection_->socket()->ReadIfReady( |
| + read_buffer_.get(), kReadBufferSize, |
| + base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), |
| + READ_STATE_DO_READ)); |
|
davidben
2017/02/01 22:25:58
Hah. That's much simpler than I expected!
xunjieli
2017/02/03 16:35:33
Acknowledged :)
|
| + // TODO(xunjieli): Follow-up CL to release |read_buffer_|. |
| + } |
| + if (rv == ERR_READ_IF_READY_NOT_IMPLEMENTED) { |
| + // Fallback to regular Read(). |
| + return connection_->socket()->Read( |
| + read_buffer_.get(), kReadBufferSize, |
| + 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) { |