Commit 209227b9 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Allow cronet to specify QUIC versions by ALPN string.

Change-Id: I0b35b89c0b9721b11932925451e2e8a2c5024740
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2005825
Auto-Submit: Ryan Hamilton <rch@chromium.org>
Reviewed-by: default avatarNick Harper <nharper@chromium.org>
Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732651}
parent 50302d08
...@@ -227,6 +227,13 @@ quic::ParsedQuicVersionVector ParseQuicVersions( ...@@ -227,6 +227,13 @@ quic::ParsedQuicVersionVector ParseQuicVersions(
} }
++it; ++it;
} }
for (const auto& supported_version : quic::AllSupportedVersions()) {
if (quic::AlpnForVersion(supported_version) == version) {
supported_versions.push_back(supported_version);
break;
}
}
} }
return supported_versions; return supported_versions;
} }
......
...@@ -349,6 +349,57 @@ TEST(URLRequestContextConfigTest, SetSupportedQuicVersion) { ...@@ -349,6 +349,57 @@ TEST(URLRequestContextConfigTest, SetSupportedQuicVersion) {
quic::QUIC_VERSION_46)); quic::QUIC_VERSION_46));
} }
TEST(URLRequestContextConfigTest, SetSupportedQuicVersionByAlpn) {
base::test::TaskEnvironment task_environment_(
base::test::TaskEnvironment::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\":\"h3-T050\"}}",
// 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;
config.ConfigureURLRequestContextBuilder(&builder);
// 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::QuicParams* quic_params = context->quic_context()->params();
EXPECT_EQ(quic_params->supported_versions.size(), 1u);
EXPECT_EQ(
quic_params->supported_versions[0],
quic::ParsedQuicVersion(quic::PROTOCOL_TLS1_3, quic::QUIC_VERSION_50));
}
TEST(URLRequestContextConfigTest, SetUnsupportedQuicVersion) { TEST(URLRequestContextConfigTest, SetUnsupportedQuicVersion) {
base::test::TaskEnvironment task_environment_( base::test::TaskEnvironment task_environment_(
base::test::TaskEnvironment::MainThreadType::IO); base::test::TaskEnvironment::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