Commit 57247968 authored by Zhongyi Shi's avatar Zhongyi Shi Committed by Commit Bot

Add knob for quic version plumbing via experimentation options in cronet

Bug: 901564
Change-Id: I5d9e5dcb34fbcb887e96652c5d27516139096a37
Reviewed-on: https://chromium-review.googlesource.com/c/1316838
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Reviewed-by: default avatarMisha Efimov <mef@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605429}
parent 7f3dd182
......@@ -83,6 +83,7 @@ const char kQuicRaceCertVerification[] = "race_cert_verification";
const char kQuicHostWhitelist[] = "host_whitelist";
const char kQuicEnableSocketRecvOptimization[] =
"enable_socket_recv_optimization";
const char kQuicVersion[] = "quic_version";
// AsyncDNS experiment dictionary name.
const char kAsyncDnsFieldTrialName[] = "AsyncDNS";
......@@ -196,6 +197,29 @@ ParseNetworkErrorLoggingHeaders(
return result;
}
quic::QuicTransportVersionVector ParseQuicVersions(
const std::string& quic_versions) {
quic::QuicTransportVersionVector supported_versions;
quic::QuicTransportVersionVector all_supported_versions =
quic::AllSupportedTransportVersions();
for (const base::StringPiece& version : base::SplitStringPiece(
quic_versions, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
auto it = all_supported_versions.begin();
while (it != all_supported_versions.end()) {
if (quic::QuicVersionToString(*it) == version) {
supported_versions.push_back(*it);
// Remove the supported version to deduplicate versions extracted from
// |quic_versions|.
all_supported_versions.erase(it);
break;
}
++it;
}
}
return supported_versions;
}
} // namespace
URLRequestContextConfig::QuicHint::QuicHint(const std::string& host,
......@@ -303,6 +327,15 @@ void URLRequestContextConfig::ParseAndSetExperimentalOptions(
effective_experimental_options->Remove(it.key(), nullptr);
continue;
}
std::string quic_version_string;
if (quic_args->GetString(kQuicVersion, &quic_version_string)) {
quic::QuicTransportVersionVector supported_versions =
ParseQuicVersions(quic_version_string);
if (!supported_versions.empty())
session_params->quic_supported_versions = supported_versions;
}
std::string quic_connection_options;
if (quic_args->GetString(kQuicConnectionOptions,
&quic_connection_options)) {
......
......@@ -281,6 +281,108 @@ TEST(URLRequestContextConfigTest, TestExperimentalOptionParsing) {
EXPECT_EQ(42.0, config.network_thread_priority.value());
}
TEST(URLRequestContextConfigTest, SetSupportedQuicVersion) {
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",
// Accept-Language request header field.
"foreign-language",
// User-Agent request header field.
"fake agent",
// JSON encoded experimental options.
"{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_44\"}}",
// 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,
// Optional network thread priority.
base::Optional<double>());
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(
std::make_unique<net::ProxyConfigServiceFixed>(
net::ProxyConfigWithAnnotation::CreateDirect()));
std::unique_ptr<net::URLRequestContext> context(builder.Build());
const net::HttpNetworkSession::Params* params =
context->GetNetworkSessionParams();
EXPECT_EQ(params->quic_supported_versions.size(), 1u);
EXPECT_EQ(params->quic_supported_versions[0], quic::QUIC_VERSION_44);
}
TEST(URLRequestContextConfigTest, SetUnsupportedQuicVersion) {
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",
// Accept-Language request header field.
"foreign-language",
// User-Agent request header field.
"fake agent",
// JSON encoded experimental options.
"{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_33\"}}",
// 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,
// Optional network thread priority.
base::Optional<double>());
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(
std::make_unique<net::ProxyConfigServiceFixed>(
net::ProxyConfigWithAnnotation::CreateDirect()));
std::unique_ptr<net::URLRequestContext> context(builder.Build());
const net::HttpNetworkSession::Params* params =
context->GetNetworkSessionParams();
EXPECT_EQ(params->quic_supported_versions.size(), 1u);
EXPECT_EQ(params->quic_supported_versions[0], quic::QUIC_VERSION_43);
}
TEST(URLRequestContextConfigTest, SetQuicServerMigrationOptions) {
base::test::ScopedTaskEnvironment scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO);
......
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