Commit 1c71894a authored by Renjie Tang's avatar Renjie Tang

Reland "Default enable QUIC in Cronet Android and IOS."

This CL also patches in crrev.com/c/2194176, which is a fix to the original CL.

This is a reland of 652185a0

Original change's description:
> Default enable QUIC in Cronet Android and IOS.
>
> This change introduces no API changes. But API documents need to be updated.
>
> Change-Id: Ibc347df79066de704c5be0683c5b658ba6e1896a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2168553
> Commit-Queue: Renjie Tang <renjietang@chromium.org>
> Reviewed-by: Zhongyi Shi <zhongyi@chromium.org>
> Reviewed-by: Misha Efimov <mef@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#765334}

Change-Id: I37f62746a35d634641febf16f29dfd1608b1e483
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235981Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777549}
parent 5bc1fa33
......@@ -64,7 +64,7 @@ public abstract class CronetEngine {
/**
* Constructs a {@link Builder} object that facilitates creating a
* {@link CronetEngine}. The default configuration enables HTTP/2 and
* disables QUIC and the HTTP cache.
* QUIC, but disables the HTTP cache.
*
* @param context Android {@link Context}, which is used by
* {@link Builder} to retrieve the application
......@@ -142,7 +142,7 @@ public abstract class CronetEngine {
/**
* Sets whether <a href="https://www.chromium.org/quic">QUIC</a> protocol
* is enabled. Defaults to disabled. If QUIC is enabled, then QUIC User Agent Id
* is enabled. Defaults to enabled. If QUIC is enabled, then QUIC User Agent Id
* containing application name and Cronet version is sent to the server.
* @param value {@code true} to enable QUIC, {@code false} to disable.
* @return the builder to facilitate chaining.
......
......@@ -93,12 +93,12 @@ public abstract class CronetEngineBuilderImpl extends ICronetEngineBuilder {
private int mThreadPriority = INVALID_THREAD_PRIORITY;
/**
* Default config enables SPDY, disables QUIC, SDCH and HTTP cache.
* Default config enables SPDY and QUIC, disables SDCH and HTTP cache.
* @param context Android {@link Context} for engine to use.
*/
public CronetEngineBuilderImpl(Context context) {
mApplicationContext = context.getApplicationContext();
enableQuic(false);
enableQuic(true);
enableHttp2(true);
enableBrotli(false);
enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISABLED, 0);
......
......@@ -45,4 +45,26 @@ static void JNI_CronetUrlRequestContextTest_VerifyUrlRequestContextConfig(
base::android::ConvertJavaStringToUTF8(env, jstorage_path));
}
// Verify that QUIC can be turned off in CronetEngine.Builder.
// Note that the config expectation is hard coded here because it's very hard to
// create an expected config in the JAVA package.
static void
JNI_CronetUrlRequestContextTest_VerifyUrlRequestContextQuicOffConfig(
JNIEnv* env,
jlong jurl_request_context_config,
const JavaParamRef<jstring>& jstorage_path) {
URLRequestContextConfig* config =
reinterpret_cast<URLRequestContextConfig*>(jurl_request_context_config);
CHECK_EQ(config->enable_spdy, false);
CHECK_EQ(config->enable_quic, false);
CHECK_EQ(config->bypass_public_key_pinning_for_local_trust_anchors, false);
CHECK_EQ(config->load_disable_cache, false);
CHECK_EQ(config->http_cache, URLRequestContextConfig::HttpCacheType::MEMORY);
CHECK_EQ(config->http_cache_max_size, 54321);
CHECK_EQ(config->user_agent, "efgh");
CHECK(!config->effective_experimental_options);
CHECK_EQ(config->storage_path,
base::android::ConvertJavaStringToUTF8(env, jstorage_path));
}
} // namespace cronet
......@@ -1251,6 +1251,35 @@ public class CronetUrlRequestContextTest {
// translated to a native UrlRequestContextConfig.
private static native void nativeVerifyUrlRequestContextConfig(long config, String storagePath);
@Test
@SmallTest
@Feature({"Cronet"})
public void testCronetEngineQuicOffConfig() throws Exception {
// This is to prompt load of native library.
mTestRule.startCronetTestFramework();
// Verify CronetEngine.Builder config is passed down accurately to native code.
ExperimentalCronetEngine.Builder builder =
new ExperimentalCronetEngine.Builder(getContext());
builder.enableHttp2(false);
// QUIC is on by default. Disabling it here to make sure the built config can correctly
// reflect the change.
builder.enableQuic(false);
builder.enableHttpCache(HTTP_CACHE_IN_MEMORY, 54321);
builder.setExperimentalOptions("ijkl");
builder.setUserAgent("efgh");
builder.setStoragePath(getTestStorage(getContext()));
builder.enablePublicKeyPinningBypassForLocalTrustAnchors(false);
nativeVerifyUrlRequestContextQuicOffConfig(
CronetUrlRequestContext.createNativeUrlRequestContextConfig(
(CronetEngineBuilderImpl) builder.mBuilderDelegate),
getTestStorage(getContext()));
}
// Verifies that CronetEngine.Builder config from testCronetEngineQuicOffConfig() is properly
// translated to a native UrlRequestContextConfig and QUIC is turned off.
private static native void nativeVerifyUrlRequestContextQuicOffConfig(
long config, String storagePath);
private static class TestBadLibraryLoader extends CronetEngine.Builder.LibraryLoader {
private boolean mWasCalled;
......
......@@ -238,7 +238,7 @@ void CronetEnvironment::AddQuicHint(const std::string& host,
CronetEnvironment::CronetEnvironment(const std::string& user_agent,
bool user_agent_partial)
: http2_enabled_(false),
quic_enabled_(false),
quic_enabled_(true),
brotli_enabled_(false),
http_cache_(URLRequestContextConfig::HttpCacheType::DISK),
user_agent_(user_agent),
......
......@@ -528,7 +528,7 @@ struct EngineParams {
* is enabled. If QUIC is enabled, then QUIC User Agent Id
* containing application name and Cronet version is sent to the server.
*/
bool enable_quic = false;
bool enable_quic = true;
/**
* Whether <a href="https://tools.ietf.org/html/rfc7540">HTTP/2</a>
......
......@@ -232,7 +232,7 @@ struct URLRequestContextConfigBuilder {
std::unique_ptr<URLRequestContextConfig> Build();
// Enable QUIC.
bool enable_quic = false;
bool enable_quic = true;
// QUIC User Agent ID.
std::string quic_user_agent_id = "";
// Enable SPDY.
......
......@@ -1119,6 +1119,24 @@ TEST(URLURLRequestContextConfigTest, TurningOffQuic) {
EXPECT_EQ(false, params->enable_quic);
}
TEST(URLURLRequestContextConfigTest, DefaultEnableQuic) {
base::test::TaskEnvironment task_environment_(
base::test::TaskEnvironment::MainThreadType::IO);
URLRequestContextConfigBuilder config_builder;
std::unique_ptr<URLRequestContextConfig> config = config_builder.Build();
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::HttpNetworkSession::Params* params =
context->GetNetworkSessionParams();
EXPECT_EQ(true, params->enable_quic);
}
// See stale_host_resolver_unittest.cc for test of StaleDNS options.
} // namespace cronet
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