Skip to content

Commit

Permalink
Allow HttpNetworkSession::Params::quic_max(_idle)_time_before_crypto_…
Browse files Browse the repository at this point in the history
…handshake to be set by Cronet experiments

Bug: 780964
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ib405bcdd6ae986f0eb2f6e1be9f360a61dbf1e3c
Reviewed-on: https://chromium-review.googlesource.com/778043
Commit-Queue: Yixin Wang <wangyix@chromium.org>
Reviewed-by: Ryan Hamilton <rch@chromium.org>
Reviewed-by: Misha Efimov <mef@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518366}
  • Loading branch information
Yixin Wang authored and Commit Bot committed Nov 21, 2017
1 parent 6316b52 commit 9838751
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
20 changes: 20 additions & 0 deletions components/cronet/url_request_context_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const char kQuicMaxServerConfigsStoredInProperties[] =
"max_server_configs_stored_in_properties";
const char kQuicIdleConnectionTimeoutSeconds[] =
"idle_connection_timeout_seconds";
const char kQuicMaxTimeBeforeCryptoHandshakeSeconds[] =
"max_time_before_crypto_handshake_seconds";
const char kQuicMaxIdleTimeBeforeCryptoHandshakeSeconds[] =
"max_idle_time_before_crypto_handshake_seconds";
const char kQuicMigrateSessionsOnNetworkChange[] =
"migrate_sessions_on_network_change";
const char kQuicMigrateSessionsOnNetworkChangeV2[] =
Expand Down Expand Up @@ -245,6 +249,22 @@ void URLRequestContextConfig::ParseAndSetExperimentalOptions(
quic_idle_connection_timeout_seconds;
}

int quic_max_time_before_crypto_handshake_seconds = 0;
if (quic_args->GetInteger(
kQuicMaxTimeBeforeCryptoHandshakeSeconds,
&quic_max_time_before_crypto_handshake_seconds)) {
session_params->quic_max_time_before_crypto_handshake_seconds =
quic_max_time_before_crypto_handshake_seconds;
}

int quic_max_idle_time_before_crypto_handshake_seconds = 0;
if (quic_args->GetInteger(
kQuicMaxIdleTimeBeforeCryptoHandshakeSeconds,
&quic_max_idle_time_before_crypto_handshake_seconds)) {
session_params->quic_max_idle_time_before_crypto_handshake_seconds =
quic_max_idle_time_before_crypto_handshake_seconds;
}

bool quic_migrate_sessions_on_network_change = false;
if (quic_args->GetBoolean(kQuicMigrateSessionsOnNetworkChange,
&quic_migrate_sessions_on_network_change)) {
Expand Down
51 changes: 51 additions & 0 deletions components/cronet/url_request_context_config_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,57 @@ TEST(URLRequestContextConfigTest, SetQuicHostWhitelist) {
base::ContainsKey(params->quic_host_whitelist, "www.example.org"));
}

TEST(URLRequestContextConfigTest, SetQuicMaxTimeBeforeCryptoHandshake) {
base::test::ScopedTaskEnvironment scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO);

URLRequestContextConfig config(
// Enable QUIC.
true,
// QUIC User Agent ID.
"Default QUIC User Agent ID",
// Enable SPDY.
true,
// Enable Brotli.
false,
// Type of http cache.
URLRequestContextConfig::HttpCacheType::DISK,
// Max size of http cache in bytes.
1024000,
// Disable caching for HTTP responses. Other information may be stored in
// the cache.
false,
// Storage path for http cache and cookie storage.
"/data/data/org.chromium.net/app_cronet_test/test_storage",
// User-Agent request header field.
"fake agent",
// JSON encoded experimental options.
"{\"QUIC\":{\"max_time_before_crypto_handshake_seconds\":7,"
"\"max_idle_time_before_crypto_handshake_seconds\":11}}",
// MockCertVerifier to use for testing purposes.
std::unique_ptr<net::CertVerifier>(),
// Enable network quality estimator.
false,
// Enable Public Key Pinning bypass for local trust anchors.
true,
// Certificate verifier cache data.
"");

net::URLRequestContextBuilder builder;
net::NetLog net_log;
config.ConfigureURLRequestContextBuilder(&builder, &net_log);
// Set a ProxyConfigService to avoid DCHECK failure when building.
builder.set_proxy_config_service(
base::MakeUnique<net::ProxyConfigServiceFixed>(
net::ProxyConfig::CreateDirect()));
std::unique_ptr<net::URLRequestContext> context(builder.Build());
const net::HttpNetworkSession::Params* params =
context->GetNetworkSessionParams();

EXPECT_EQ(7, params->quic_max_time_before_crypto_handshake_seconds);
EXPECT_EQ(11, params->quic_max_idle_time_before_crypto_handshake_seconds);
}

// See stale_host_resolver_unittest.cc for test of StaleDNS options.

} // namespace cronet

0 comments on commit 9838751

Please sign in to comment.