Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1537)

Unified Diff: net/spdy/spdy_session.cc

Issue 2593063003: Add Socket::ReadIfReady() (Closed)
Patch Set: self review. remove unused include Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/spdy/spdy_session.cc
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 431022624477c12cdb079655abc77cb9b7723f39..edf73acd901451398456d6149d6cb08ebc2e053e 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/feature_list.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.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/platform/api/spdy_estimate_memory_usage.h"
#include "net/spdy/spdy_buffer_producer.h"
@@ -1804,6 +1806,32 @@ void SpdySession::PumpReadLoop(ReadState expected_read_state, int result) {
ignore_result(DoReadLoop(expected_read_state, result));
}
+int SpdySession::DoRead() {
Bence 2017/03/03 16:33:41 Oh no, I just reordered methods in https://crrev.c
xunjieli 2017/03/03 19:41:06 Done.
+ CHECK(in_io_loop_);
+
+ CHECK(connection_);
+ CHECK(connection_->socket());
Bence 2017/03/03 16:33:42 Do you think this would flow more naturally? if (
xunjieli 2017/03/03 19:41:06 I may be biased, but I like my verson better. Fewe
Bence 2017/03/06 23:43:14 It's okay to be biased, you are the author. :)
+ read_state_ = READ_STATE_DO_READ_COMPLETE;
+ int rv = ERR_READ_IF_READY_NOT_IMPLEMENTED;
+ 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_|. crbug.com/524258.
Bence 2017/03/03 16:33:42 Optional: use https:// prefix for crbug, because s
xunjieli 2017/03/03 19:41:06 Done. I personally avoid the https:// prefix becau
Bence 2017/03/06 23:43:14 I guess then you are not using vim in gnome-termin
+ }
+ 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);
@@ -1857,18 +1885,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_);

Powered by Google App Engine
This is Rietveld 408576698