Commit 2b966f21 authored by jri's avatar jri Committed by Commit bot

Adds plumbing for always requiring handshake confirmation in QUIC, for use in Finch field trials.

BUG=

Review URL: https://codereview.chromium.org/524463004

Cr-Commit-Position: refs/heads/master@{#293010}
parent a5f8ead4
...@@ -1046,6 +1046,8 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals( ...@@ -1046,6 +1046,8 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals(
globals.enable_quic.CopyToIfSet(&params->enable_quic); globals.enable_quic.CopyToIfSet(&params->enable_quic);
globals.enable_quic_time_based_loss_detection.CopyToIfSet( globals.enable_quic_time_based_loss_detection.CopyToIfSet(
&params->enable_quic_time_based_loss_detection); &params->enable_quic_time_based_loss_detection);
globals.quic_always_require_handshake_confirmation.CopyToIfSet(
&params->quic_always_require_handshake_confirmation);
globals.enable_quic_port_selection.CopyToIfSet( globals.enable_quic_port_selection.CopyToIfSet(
&params->enable_quic_port_selection); &params->enable_quic_port_selection);
globals.quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length); globals.quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length);
...@@ -1159,6 +1161,8 @@ void IOThread::ConfigureQuicGlobals( ...@@ -1159,6 +1161,8 @@ void IOThread::ConfigureQuicGlobals(
globals->enable_quic_time_based_loss_detection.set( globals->enable_quic_time_based_loss_detection.set(
ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group, ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group,
quic_trial_params)); quic_trial_params));
globals->quic_always_require_handshake_confirmation.set(
ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params));
globals->enable_quic_port_selection.set( globals->enable_quic_port_selection.set(
ShouldEnableQuicPortSelection(command_line)); ShouldEnableQuicPortSelection(command_line));
globals->quic_connection_options = globals->quic_connection_options =
...@@ -1333,6 +1337,15 @@ bool IOThread::ShouldEnableQuicTimeBasedLossDetection( ...@@ -1333,6 +1337,15 @@ bool IOThread::ShouldEnableQuicTimeBasedLossDetection(
kQuicFieldTrialTimeBasedLossDetectionSuffix); kQuicFieldTrialTimeBasedLossDetectionSuffix);
} }
// static
bool IOThread::ShouldQuicAlwaysRequireHandshakeConfirmation(
const VariationParameters& quic_trial_params) {
return LowerCaseEqualsASCII(
GetVariationParam(quic_trial_params,
"always_require_handshake_confirmation"),
"true");
}
// static // static
size_t IOThread::GetQuicMaxPacketLength( size_t IOThread::GetQuicMaxPacketLength(
const CommandLine& command_line, const CommandLine& command_line,
......
...@@ -187,6 +187,7 @@ class IOThread : public content::BrowserThreadDelegate { ...@@ -187,6 +187,7 @@ class IOThread : public content::BrowserThreadDelegate {
Optional<bool> enable_quic; Optional<bool> enable_quic;
Optional<bool> enable_quic_time_based_loss_detection; Optional<bool> enable_quic_time_based_loss_detection;
Optional<bool> enable_quic_port_selection; Optional<bool> enable_quic_port_selection;
Optional<bool> quic_always_require_handshake_confirmation;
Optional<size_t> quic_max_packet_length; Optional<size_t> quic_max_packet_length;
net::QuicTagVector quic_connection_options; net::QuicTagVector quic_connection_options;
Optional<std::string> quic_user_agent_id; Optional<std::string> quic_user_agent_id;
...@@ -352,6 +353,11 @@ class IOThread : public content::BrowserThreadDelegate { ...@@ -352,6 +353,11 @@ class IOThread : public content::BrowserThreadDelegate {
base::StringPiece quic_trial_group, base::StringPiece quic_trial_group,
const VariationParameters& quic_trial_params); const VariationParameters& quic_trial_params);
// Returns true if QUIC should always require handshake confirmation during
// the QUIC handshake.
static bool ShouldQuicAlwaysRequireHandshakeConfirmation(
const VariationParameters& quic_trial_params);
// Returns the maximum length for QUIC packets, based on any flags in // Returns the maximum length for QUIC packets, based on any flags in
// |command_line| or the field trial. Returns 0 if there is an error // |command_line| or the field trial. Returns 0 if there is an error
// parsing any of the options, or if the default value should be used. // parsing any of the options, or if the default value should be used.
......
...@@ -132,6 +132,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { ...@@ -132,6 +132,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) {
EXPECT_EQ(default_params.quic_supported_versions, EXPECT_EQ(default_params.quic_supported_versions,
params.quic_supported_versions); params.quic_supported_versions);
EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options);
EXPECT_FALSE(params.quic_always_require_handshake_confirmation);
} }
TEST_F(IOThreadTest, EnableQuicFromCommandLine) { TEST_F(IOThreadTest, EnableQuicFromCommandLine) {
...@@ -320,4 +321,14 @@ TEST_F(IOThreadTest, QuicConnectionOptionsFromDeprecatedFieldTrialParams) { ...@@ -320,4 +321,14 @@ TEST_F(IOThreadTest, QuicConnectionOptionsFromDeprecatedFieldTrialParams) {
EXPECT_EQ(options, params.quic_connection_options); EXPECT_EQ(options, params.quic_connection_options);
} }
TEST_F(IOThreadTest,
QuicAlwaysRequireHandshakeConfirmationFromFieldTrialParams) {
field_trial_group_ = "Enabled";
field_trial_params_["always_require_handshake_confirmation"] = "true";
ConfigureQuicGlobals();
net::HttpNetworkSession::Params params;
InitializeNetworkSessionParams(&params);
EXPECT_TRUE(params.quic_always_require_handshake_confirmation);
}
} // namespace test } // namespace test
...@@ -90,6 +90,7 @@ HttpNetworkSession::Params::Params() ...@@ -90,6 +90,7 @@ HttpNetworkSession::Params::Params()
enable_quic(false), enable_quic(false),
enable_quic_port_selection(true), enable_quic_port_selection(true),
enable_quic_time_based_loss_detection(false), enable_quic_time_based_loss_detection(false),
quic_always_require_handshake_confirmation(false),
quic_clock(NULL), quic_clock(NULL),
quic_random(NULL), quic_random(NULL),
quic_max_packet_length(kDefaultMaxPacketSize), quic_max_packet_length(kDefaultMaxPacketSize),
...@@ -113,25 +114,25 @@ HttpNetworkSession::HttpNetworkSession(const Params& params) ...@@ -113,25 +114,25 @@ HttpNetworkSession::HttpNetworkSession(const Params& params)
CreateSocketPoolManager(NORMAL_SOCKET_POOL, params)), CreateSocketPoolManager(NORMAL_SOCKET_POOL, params)),
websocket_socket_pool_manager_( websocket_socket_pool_manager_(
CreateSocketPoolManager(WEBSOCKET_SOCKET_POOL, params)), CreateSocketPoolManager(WEBSOCKET_SOCKET_POOL, params)),
quic_stream_factory_(params.host_resolver, quic_stream_factory_(
params.client_socket_factory ? params.host_resolver,
params.client_socket_factory : params.client_socket_factory
net::ClientSocketFactory::GetDefaultFactory(), ? params.client_socket_factory
params.http_server_properties, : net::ClientSocketFactory::GetDefaultFactory(),
params.cert_verifier, params.http_server_properties,
params.channel_id_service, params.cert_verifier,
params.transport_security_state, params.channel_id_service,
params.quic_crypto_client_stream_factory, params.transport_security_state,
params.quic_random ? params.quic_random : params.quic_crypto_client_stream_factory,
QuicRandom::GetInstance(), params.quic_random ? params.quic_random : QuicRandom::GetInstance(),
params.quic_clock ? params. quic_clock : params.quic_clock ? params.quic_clock : new QuicClock(),
new QuicClock(), params.quic_max_packet_length,
params.quic_max_packet_length, params.quic_user_agent_id,
params.quic_user_agent_id, params.quic_supported_versions,
params.quic_supported_versions, params.enable_quic_port_selection,
params.enable_quic_port_selection, params.enable_quic_time_based_loss_detection,
params.enable_quic_time_based_loss_detection, params.quic_always_require_handshake_confirmation,
params.quic_connection_options), params.quic_connection_options),
spdy_session_pool_(params.host_resolver, spdy_session_pool_(params.host_resolver,
params.ssl_config_service, params.ssl_config_service,
params.http_server_properties, params.http_server_properties,
...@@ -146,8 +147,7 @@ HttpNetworkSession::HttpNetworkSession(const Params& params) ...@@ -146,8 +147,7 @@ HttpNetworkSession::HttpNetworkSession(const Params& params)
params.time_func, params.time_func,
params.trusted_spdy_proxy), params.trusted_spdy_proxy),
http_stream_factory_(new HttpStreamFactoryImpl(this, false)), http_stream_factory_(new HttpStreamFactoryImpl(this, false)),
http_stream_factory_for_websocket_( http_stream_factory_for_websocket_(new HttpStreamFactoryImpl(this, true)),
new HttpStreamFactoryImpl(this, true)),
params_(params) { params_(params) {
DCHECK(proxy_service_); DCHECK(proxy_service_);
DCHECK(ssl_config_service_.get()); DCHECK(ssl_config_service_.get());
......
...@@ -111,6 +111,7 @@ class NET_EXPORT HttpNetworkSession ...@@ -111,6 +111,7 @@ class NET_EXPORT HttpNetworkSession
bool enable_quic; bool enable_quic;
bool enable_quic_port_selection; bool enable_quic_port_selection;
bool enable_quic_time_based_loss_detection; bool enable_quic_time_based_loss_detection;
bool quic_always_require_handshake_confirmation;
HostPortPair origin_to_force_quic_on; HostPortPair origin_to_force_quic_on;
QuicClock* quic_clock; // Will be owned by QuicStreamFactory. QuicClock* quic_clock; // Will be owned by QuicStreamFactory.
QuicRandom* quic_random; QuicRandom* quic_random;
......
...@@ -481,6 +481,7 @@ QuicStreamFactory::QuicStreamFactory( ...@@ -481,6 +481,7 @@ QuicStreamFactory::QuicStreamFactory(
const QuicVersionVector& supported_versions, const QuicVersionVector& supported_versions,
bool enable_port_selection, bool enable_port_selection,
bool enable_time_based_loss_detection, bool enable_time_based_loss_detection,
bool always_require_handshake_confirmation,
const QuicTagVector& connection_options) const QuicTagVector& connection_options)
: require_confirmation_(true), : require_confirmation_(true),
host_resolver_(host_resolver), host_resolver_(host_resolver),
...@@ -496,6 +497,8 @@ QuicStreamFactory::QuicStreamFactory( ...@@ -496,6 +497,8 @@ QuicStreamFactory::QuicStreamFactory(
connection_options)), connection_options)),
supported_versions_(supported_versions), supported_versions_(supported_versions),
enable_port_selection_(enable_port_selection), enable_port_selection_(enable_port_selection),
always_require_handshake_confirmation_(
always_require_handshake_confirmation),
port_seed_(random_generator_->RandUint64()), port_seed_(random_generator_->RandUint64()),
weak_factory_(this) { weak_factory_(this) {
DCHECK(transport_security_state_); DCHECK(transport_security_state_);
...@@ -599,7 +602,8 @@ bool QuicStreamFactory::OnResolution( ...@@ -599,7 +602,8 @@ bool QuicStreamFactory::OnResolution(
void QuicStreamFactory::OnJobComplete(Job* job, int rv) { void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
if (rv == OK) { if (rv == OK) {
require_confirmation_ = false; if (!always_require_handshake_confirmation_)
require_confirmation_ = false;
// Create all the streams, but do not notify them yet. // Create all the streams, but do not notify them yet.
for (RequestSet::iterator it = job_requests_map_[job].begin(); for (RequestSet::iterator it = job_requests_map_[job].begin();
......
...@@ -103,6 +103,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory ...@@ -103,6 +103,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
const QuicVersionVector& supported_versions, const QuicVersionVector& supported_versions,
bool enable_port_selection, bool enable_port_selection,
bool enable_time_based_loss_detection, bool enable_time_based_loss_detection,
bool always_require_handshake_confirmation,
const QuicTagVector& connection_options); const QuicTagVector& connection_options);
virtual ~QuicStreamFactory(); virtual ~QuicStreamFactory();
...@@ -154,7 +155,9 @@ class NET_EXPORT_PRIVATE QuicStreamFactory ...@@ -154,7 +155,9 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE; virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE;
virtual void OnCACertChanged(const X509Certificate* cert) OVERRIDE; virtual void OnCACertChanged(const X509Certificate* cert) OVERRIDE;
bool require_confirmation() const { return require_confirmation_; } bool require_confirmation() const {
return require_confirmation_;
}
void set_require_confirmation(bool require_confirmation) { void set_require_confirmation(bool require_confirmation) {
require_confirmation_ = require_confirmation; require_confirmation_ = require_confirmation;
...@@ -274,6 +277,10 @@ class NET_EXPORT_PRIVATE QuicStreamFactory ...@@ -274,6 +277,10 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
// connection. // connection.
bool enable_port_selection_; bool enable_port_selection_;
// Set if we always require handshake confirmation. If true, this will
// introduce at least one RTT for the handshake before the client sends data.
bool always_require_handshake_confirmation_;
// Each profile will (probably) have a unique port_seed_ value. This value is // Each profile will (probably) have a unique port_seed_ value. This value is
// used to help seed a pseudo-random number generator (PortSuggester) so that // used to help seed a pseudo-random number generator (PortSuggester) so that
// we consistently (within this profile) suggest the same ephemeral port when // we consistently (within this profile) suggest the same ephemeral port when
......
...@@ -93,15 +93,25 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> { ...@@ -93,15 +93,25 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
clock_(new MockClock()), clock_(new MockClock()),
maker_(GetParam(), 0, clock_), maker_(GetParam(), 0, clock_),
cert_verifier_(CertVerifier::CreateDefault()), cert_verifier_(CertVerifier::CreateDefault()),
channel_id_service_(new ChannelIDService( channel_id_service_(
new DefaultChannelIDStore(NULL), new ChannelIDService(new DefaultChannelIDStore(NULL),
base::MessageLoopProxy::current())), base::MessageLoopProxy::current())),
factory_(&host_resolver_, &socket_factory_, factory_(&host_resolver_,
base::WeakPtr<HttpServerProperties>(), cert_verifier_.get(), &socket_factory_,
channel_id_service_.get(), &transport_security_state_, base::WeakPtr<HttpServerProperties>(),
&crypto_client_stream_factory_, &random_generator_, clock_, cert_verifier_.get(),
kDefaultMaxPacketSize, std::string(), channel_id_service_.get(),
SupportedVersions(GetParam()), true, true, QuicTagVector()), &transport_security_state_,
&crypto_client_stream_factory_,
&random_generator_,
clock_,
kDefaultMaxPacketSize,
std::string(),
SupportedVersions(GetParam()),
/*enable_port_selection=*/true,
/*enable_time_based_loss_detection=*/true,
/*always_require_handshake_confirmation=*/true,
QuicTagVector()),
host_port_pair_(kDefaultServerHostName, kDefaultServerPort), host_port_pair_(kDefaultServerHostName, kDefaultServerPort),
is_https_(false), is_https_(false),
privacy_mode_(PRIVACY_MODE_DISABLED) { privacy_mode_(PRIVACY_MODE_DISABLED) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment