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

Unified Diff: net/socket/transport_client_socket_pool.cc

Issue 451383002: Plumbing for TCP FastOpen for SSL sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. Created 6 years, 3 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/socket/transport_client_socket_pool.cc
diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc
index 7527eca52edf547d3e75a102bf8b79374ba846a8..4a61a1596e065735a30d5b9d3b1661064a29c551 100644
--- a/net/socket/transport_client_socket_pool.cc
+++ b/net/socket/transport_client_socket_pool.cc
@@ -25,6 +25,8 @@
#include "net/socket/tcp_client_socket.h"
using base::TimeDelta;
+extern bool g_tcp_fastopen_user_enabled;
+extern bool g_tcp_fastopen_supported;
namespace net {
@@ -60,12 +62,24 @@ TransportSocketParams::TransportSocketParams(
const HostPortPair& host_port_pair,
bool disable_resolver_cache,
bool ignore_limits,
- const OnHostResolutionCallback& host_resolution_callback)
+ const OnHostResolutionCallback& host_resolution_callback,
+ CombineConnectAndWritePolicy combine_connect_and_write_if_supported)
: destination_(host_port_pair),
ignore_limits_(ignore_limits),
- host_resolution_callback_(host_resolution_callback) {
+ host_resolution_callback_(host_resolution_callback),
+ combine_connect_and_write_(combine_connect_and_write_if_supported) {
if (disable_resolver_cache)
destination_.set_allow_cached_response(false);
+ // combine_connect_and_write currently translates to TCP FastOpen.
+ // Enable TCP FastOpen if user wants it and system supports it.
+ if (!g_tcp_fastopen_supported) {
+ combine_connect_and_write_ = COMBINE_CONNECT_AND_WRITE_PROHIBITED;
+ } else {
+ if (g_tcp_fastopen_user_enabled &&
+ combine_connect_and_write_ == COMBINE_CONNECT_AND_WRITE_DEFAULT) {
+ combine_connect_and_write_ = COMBINE_CONNECT_AND_WRITE_DESIRED;
+ }
+ }
}
TransportSocketParams::~TransportSocketParams() {}
@@ -261,10 +275,21 @@ int TransportConnectJob::DoTransportConnect() {
transport_socket_ =
helper_.client_socket_factory()->CreateTransportClientSocket(
helper_.addresses(), net_log().net_log(), net_log().source());
- int rv = transport_socket_->Connect(helper_.on_io_complete());
- if (rv == ERR_IO_PENDING &&
+
+ bool try_ipv6_connect_with_ipv4_fallback =
mmenke 2014/09/10 17:32:23 optional: Maybe add a comment? Something like "I
Jana 2014/09/11 16:02:36 Done. Also added an RFC number to make it look off
helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 &&
- !AddressListOnlyContainsIPv6(helper_.addresses())) {
+ !AddressListOnlyContainsIPv6(helper_.addresses());
+
+ // Enable TCP FastOpen if indicated by transport socket params.
+ // Note: We currently do not turn on TCP FastOpen for destinations where
+ // we try a TCP connect over IPv6 with fallback to IPv4.
+ if (!try_ipv6_connect_with_ipv4_fallback &&
+ helper_.params()->combine_connect_and_write() ==
+ TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED)
+ transport_socket_->EnableTCPFastOpen();
mmenke 2014/09/10 17:32:22 nit: Use braces when the conditional takes more t
Jana 2014/09/11 16:02:36 Done.
+
+ int rv = transport_socket_->Connect(helper_.on_io_complete());
+ if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) {
fallback_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(

Powered by Google App Engine
This is Rietveld 408576698