Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index 2e3a31a457d7007b28022827c9cf73296ca9202e..6def68c695ac8a7986f62f1047cde889e36861cf 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" |
davidben
2017/02/10 23:33:49
No longer used.
xunjieli
2017/02/13 20:28:19
Done.
|
#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" |
@@ -1776,6 +1778,32 @@ void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) { |
ignore_result(DoReadLoop(expected_read_state, result)); |
} |
+int SpdySession::DoRead() { |
+ CHECK(in_io_loop_); |
+ |
+ CHECK(connection_); |
+ CHECK(connection_->socket()); |
+ read_state_ = READ_STATE_DO_READ_COMPLETE; |
+ int rv = ERR_READ_IF_READY_NOT_IMPLEMENTED; |
+ if (base::FeatureList::IsEnabled(Socket::kReadIfReadyExperiment)) { |
davidben
2017/02/10 23:33:49
#include "base/feature_list.h"
xunjieli
2017/02/13 20:28:19
Done.
|
+ 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_|. crbug.com/524258. |
+ } |
+ 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::DoReadLoop(ReadState expected_read_state, int result) { |
CHECK(!in_io_loop_); |
CHECK_EQ(read_state_, expected_read_state); |
@@ -1829,18 +1857,6 @@ int SpdySession::DoReadLoop(ReadState expected_read_state, int result) { |
return result; |
} |
-int SpdySession::DoRead() { |
- CHECK(in_io_loop_); |
- |
- 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 SpdySession::DoReadComplete(int result) { |
CHECK(in_io_loop_); |