Allow QUIC whitelist to be set via Finch or Cronet experiments
If whitelist is specified and non-empty, QUIC can only be spoken to hosts in the whitelist.
Bug: 781392
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I2d48262c5449d232bb73eebc7a1683d18e7f8954
Reviewed-on: https://chromium-review.googlesource.com/772826
Commit-Queue: Yixin Wang <[email protected]>
Reviewed-by: Ryan Hamilton <[email protected]>
Reviewed-by: Misha Efimov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#518108}
diff --git a/components/cronet/url_request_context_config_unittest.cc b/components/cronet/url_request_context_config_unittest.cc
index 064c156..6447879 100644
--- a/components/cronet/url_request_context_config_unittest.cc
+++ b/components/cronet/url_request_context_config_unittest.cc
@@ -160,7 +160,7 @@
EXPECT_TRUE(params->quic_migrate_sessions_early);
}
-TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationiV2Options) {
+TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationV2Options) {
base::test::ScopedTaskEnvironment scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO);
@@ -209,6 +209,58 @@
EXPECT_TRUE(params->quic_migrate_sessions_on_network_change_v2);
}
+TEST(URLRequestContextConfigTest, SetQuicHostWhitelist) {
+ 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\":{\"host_whitelist\":\"www.example.com,www.example.org\"}}",
+ // 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_TRUE(
+ base::ContainsKey(params->quic_host_whitelist, "www.example.com"));
+ EXPECT_TRUE(
+ base::ContainsKey(params->quic_host_whitelist, "www.example.org"));
+}
+
// See stale_host_resolver_unittest.cc for test of StaleDNS options.
} // namespace cronet