Commit f24ee5f5 authored by xunjieli's avatar xunjieli Committed by Commit bot

[Cronet] Add QUIC experimental params

This CL plumbs four QUIC experimental params (
quic_store_server_configs_in_properties,
quic_delay_tcp_race,
quic_max_number_of_lossy_connections,
quic_packet_loss_threshold) from Cronet's
setExperimentalOptions API to net::HttpNetworkSession.

This CL also adds a unittests target to run the unittests.
A followup CL will enable the unittests on the cronet bots.

BUG=545118

Committed: https://crrev.com/fde0b72c603cd111c36ca4cc416d82a7395bcf6c
Cr-Commit-Position: refs/heads/master@{#360454}

Committed: https://crrev.com/8ece3aa6845350c1971a3e824bf148f3e8de3253
Cr-Commit-Position: refs/heads/master@{#360875}

Review URL: https://codereview.chromium.org/1448583003

Cr-Commit-Position: refs/heads/master@{#361138}
parent 96ecfe9a
...@@ -226,9 +226,6 @@ ...@@ -226,9 +226,6 @@
'copresence/rpc/rpc_handler_unittest.cc', 'copresence/rpc/rpc_handler_unittest.cc',
'copresence/timed_map_unittest.cc', 'copresence/timed_map_unittest.cc',
], ],
'cronet_unittest_sources': [
'cronet/histogram_manager_unittest.cc',
],
'data_use_measurement_unittest_sources': [ 'data_use_measurement_unittest_sources': [
'data_use_measurement/content/data_use_measurement_unittest.cc', 'data_use_measurement/content/data_use_measurement_unittest.cc',
], ],
...@@ -1288,7 +1285,6 @@ ...@@ -1288,7 +1285,6 @@
}], }],
['OS == "android"', { ['OS == "android"', {
'sources': [ 'sources': [
'<@(cronet_unittest_sources)',
'data_reduction_proxy/content/browser/data_reduction_proxy_debug_blocking_page_unittest.cc', 'data_reduction_proxy/content/browser/data_reduction_proxy_debug_blocking_page_unittest.cc',
'data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc', 'data_reduction_proxy/content/browser/data_reduction_proxy_debug_resource_throttle_unittest.cc',
'data_reduction_proxy/content/browser/data_reduction_proxy_debug_ui_manager_unittest.cc', 'data_reduction_proxy/content/browser/data_reduction_proxy_debug_ui_manager_unittest.cc',
...@@ -1311,7 +1307,6 @@ ...@@ -1311,7 +1307,6 @@
'web_modal/web_contents_modal_dialog_manager_unittest.cc', 'web_modal/web_contents_modal_dialog_manager_unittest.cc',
], ],
'dependencies': [ 'dependencies': [
'components.gyp:cronet_static',
'components.gyp:data_reduction_proxy_content', 'components.gyp:data_reduction_proxy_content',
'components.gyp:data_usage_android', 'components.gyp:data_usage_android',
'components.gyp:safe_json_java', 'components.gyp:safe_json_java',
......
...@@ -164,6 +164,7 @@ ...@@ -164,6 +164,7 @@
], ],
'dependencies': [ 'dependencies': [
'../net/net.gyp:net_small', '../net/net.gyp:net_small',
'../url/url.gyp:url_lib_use_icu_alternatives_on_android',
], ],
'conditions': [ 'conditions': [
['enable_data_reduction_proxy_support==1', ['enable_data_reduction_proxy_support==1',
...@@ -183,6 +184,7 @@ ...@@ -183,6 +184,7 @@
'dependencies': [ 'dependencies': [
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../net/net.gyp:net', '../net/net.gyp:net',
'../url/url.gyp:url_lib',
], ],
'conditions': [ 'conditions': [
['enable_data_reduction_proxy_support==1', ['enable_data_reduction_proxy_support==1',
...@@ -205,7 +207,6 @@ ...@@ -205,7 +207,6 @@
'cronet_static_small', 'cronet_static_small',
'../base/base.gyp:base', '../base/base.gyp:base',
'../net/net.gyp:net_small', '../net/net.gyp:net_small',
'../url/url.gyp:url_lib_use_icu_alternatives_on_android',
], ],
}, },
{ # cronet_api.jar defines Cronet API and provides implementation of { # cronet_api.jar defines Cronet API and provides implementation of
...@@ -363,7 +364,6 @@ ...@@ -363,7 +364,6 @@
'../net/net.gyp:net_quic_proto', '../net/net.gyp:net_quic_proto',
'../net/net.gyp:net_test_support', '../net/net.gyp:net_test_support',
'../net/net.gyp:simple_quic_tools', '../net/net.gyp:simple_quic_tools',
'../url/url.gyp:url_lib',
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
...@@ -445,6 +445,36 @@ ...@@ -445,6 +445,36 @@
}, },
'includes': [ '../build/java_apk.gypi' ], 'includes': [ '../build/java_apk.gypi' ],
}, },
{
'target_name': 'cronet_unittests',
'type': '<(gtest_target_type)',
'dependencies': [
'cronet_static',
'metrics',
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
'../testing/gtest.gyp:gtest',
'../testing/android/native_test.gyp:native_test_native_code',
],
'sources': [
'cronet/run_all_unittests.cc',
'cronet/url_request_context_config_unittest.cc',
'cronet/histogram_manager_unittest.cc',
],
},
{
'target_name': 'cronet_unittests_apk',
'type': 'none',
'dependencies': [
'cronet_unittests',
],
'variables': {
'test_suite_name': 'cronet_unittests',
},
'includes': [
'../build/apk_test.gypi',
],
},
{ {
'target_name': 'cronet_package', 'target_name': 'cronet_package',
'type': 'none', 'type': 'none',
......
...@@ -38,8 +38,12 @@ public class QuicTest extends CronetTestBase { ...@@ -38,8 +38,12 @@ public class QuicTest extends CronetTestBase {
builder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getServerPort(), builder.addQuicHint(QuicTestServer.getServerHost(), QuicTestServer.getServerPort(),
QuicTestServer.getServerPort()); QuicTestServer.getServerPort());
JSONObject quicParams = JSONObject quicParams = new JSONObject()
new JSONObject().put("connection_options", "PACE,IW10,FOO,DEADBEEF"); .put("connection_options", "PACE,IW10,FOO,DEADBEEF")
.put("store_server_configs_in_properties", true)
.put("delay_tcp_race", true)
.put("max_number_of_lossy_connections", 10)
.put("packet_loss_threshold", 0.5);
JSONObject experimentalOptions = new JSONObject().put("QUIC", quicParams); JSONObject experimentalOptions = new JSONObject().put("QUIC", quicParams);
builder.setExperimentalOptions(experimentalOptions.toString()); builder.setExperimentalOptions(experimentalOptions.toString());
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
int main(int argc, char** argv) {
base::TestSuite test_suite(argc, argv);
return base::LaunchUnitTests(
argc, argv,
base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
}
...@@ -22,6 +22,12 @@ namespace { ...@@ -22,6 +22,12 @@ namespace {
// TODO(xunjieli): Refactor constants in io_thread.cc. // TODO(xunjieli): Refactor constants in io_thread.cc.
const char kQuicFieldTrialName[] = "QUIC"; const char kQuicFieldTrialName[] = "QUIC";
const char kQuicConnectionOptions[] = "connection_options"; const char kQuicConnectionOptions[] = "connection_options";
const char kQuicStoreServerConfigsInProperties[] =
"store_server_configs_in_properties";
const char kQuicDelayTcpRace[] = "delay_tcp_race";
const char kQuicMaxNumberOfLossyConnections[] =
"max_number_of_lossy_connections";
const char kQuicPacketLossThreshold[] = "packet_loss_threshold";
// Using a reference to scoped_ptr is unavoidable because of the semantics of // Using a reference to scoped_ptr is unavoidable because of the semantics of
// RegisterCustomField. // RegisterCustomField.
...@@ -41,6 +47,7 @@ void ParseAndSetExperimentalOptions( ...@@ -41,6 +47,7 @@ void ParseAndSetExperimentalOptions(
if (experimental_options.empty()) if (experimental_options.empty())
return; return;
DVLOG(1) << "Experimental Options:" << experimental_options;
scoped_ptr<base::Value> options = scoped_ptr<base::Value> options =
base::JSONReader::Read(experimental_options); base::JSONReader::Read(experimental_options);
...@@ -67,6 +74,32 @@ void ParseAndSetExperimentalOptions( ...@@ -67,6 +74,32 @@ void ParseAndSetExperimentalOptions(
context_builder->set_quic_connection_options( context_builder->set_quic_connection_options(
net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options)); net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options));
} }
bool quic_store_server_configs_in_properties = false;
if (quic_args->GetBoolean(kQuicStoreServerConfigsInProperties,
&quic_store_server_configs_in_properties)) {
context_builder->set_quic_store_server_configs_in_properties(
quic_store_server_configs_in_properties);
}
bool quic_delay_tcp_race = false;
if (quic_args->GetBoolean(kQuicDelayTcpRace, &quic_delay_tcp_race)) {
context_builder->set_quic_delay_tcp_race(quic_delay_tcp_race);
}
int quic_max_number_of_lossy_connections = 0;
if (quic_args->GetInteger(kQuicMaxNumberOfLossyConnections,
&quic_max_number_of_lossy_connections)) {
context_builder->set_quic_max_number_of_lossy_connections(
quic_max_number_of_lossy_connections);
}
double quic_packet_loss_threshold = 0.0;
if (quic_args->GetDouble(kQuicPacketLossThreshold,
&quic_packet_loss_threshold)) {
context_builder->set_quic_packet_loss_threshold(
quic_packet_loss_threshold);
}
} }
} }
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cronet/url_request_context_config.h"
#include "net/http/http_network_session.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cronet {
TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) {
URLRequestContextConfig config;
std::string args =
"{\"QUIC_HINTS\":[{\"QUIC_HINT_ALT_PORT\":6121,\"QUIC_HINT_PORT\":6121,"
"\"QUIC_HINT_HOST\":\"test.example.com\"}],"
"\"HTTP_CACHE\":\"HTTP_CACHE_DISK\",\"ENABLE_SDCH\":false,"
"\"ENABLE_LEGACY_MODE\":false,\"HTTP_CACHE_MAX_SIZE\":1024000,"
"\"NATIVE_LIBRARY_NAME\":\"cronet_tests\",\"USER_AGENT\":\"fake agent\","
"\"STORAGE_PATH\":"
"\"\\/data\\/data\\/org.chromium.net\\/app_cronet_test\\/test_storage\","
"\"ENABLE_SPDY\":true,"
"\"ENABLE_QUIC\":true,\"LOAD_DISABLE_CACHE\":true,"
"\"EXPERIMENTAL_OPTIONS\":"
"\"{\\\"QUIC\\\":{\\\"store_server_configs_in_properties\\\":true,"
"\\\"delay_tcp_race\\\":true,"
"\\\"max_number_of_lossy_connections\\\":10,"
"\\\"packet_loss_threshold\\\":0.5,"
"\\\"connection_options\\\":\\\"TIME,TBBR,REJ\\\"}}\"}";
config.LoadFromJSON(args);
net::URLRequestContextBuilder builder;
config.ConfigureURLRequestContextBuilder(&builder);
// Set a ProxyConfigService to avoid DCHECK failure when building.
builder.set_proxy_config_service(make_scoped_ptr(
new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect())));
scoped_ptr<net::URLRequestContext> context(builder.Build());
const net::HttpNetworkSession::Params* params =
context->GetNetworkSessionParams();
// Check Quic Connection options.
net::QuicTagVector quic_connection_options;
quic_connection_options.push_back(net::kTIME);
quic_connection_options.push_back(net::kTBBR);
quic_connection_options.push_back(net::kREJ);
EXPECT_EQ(quic_connection_options, params->quic_connection_options);
// Check store_server_configs_in_properties.
EXPECT_TRUE(params->quic_store_server_configs_in_properties);
// Check delay_tcp_race.
EXPECT_TRUE(params->quic_delay_tcp_race);
// Check max_number_of_lossy_connections and packet_loss_threshold.
EXPECT_EQ(10, params->quic_max_number_of_lossy_connections);
EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold);
}
} // namespace cronet
...@@ -177,7 +177,11 @@ URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() ...@@ -177,7 +177,11 @@ URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams()
testing_fixed_https_port(0), testing_fixed_https_port(0),
next_protos(NextProtosDefaults()), next_protos(NextProtosDefaults()),
use_alternative_services(true), use_alternative_services(true),
enable_quic(false) {} enable_quic(false),
quic_store_server_configs_in_properties(false),
quic_delay_tcp_race(false),
quic_max_number_of_lossy_connections(0),
quic_packet_loss_threshold(1.0f) {}
URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams()
{} {}
...@@ -389,6 +393,14 @@ scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() { ...@@ -389,6 +393,14 @@ scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
http_network_session_params_.trusted_spdy_proxy; http_network_session_params_.trusted_spdy_proxy;
network_session_params.next_protos = http_network_session_params_.next_protos; network_session_params.next_protos = http_network_session_params_.next_protos;
network_session_params.enable_quic = http_network_session_params_.enable_quic; network_session_params.enable_quic = http_network_session_params_.enable_quic;
network_session_params.quic_store_server_configs_in_properties =
http_network_session_params_.quic_store_server_configs_in_properties;
network_session_params.quic_delay_tcp_race =
http_network_session_params_.quic_delay_tcp_race;
network_session_params.quic_max_number_of_lossy_connections =
http_network_session_params_.quic_max_number_of_lossy_connections;
network_session_params.quic_packet_loss_threshold =
http_network_session_params_.quic_packet_loss_threshold;
network_session_params.quic_connection_options = network_session_params.quic_connection_options =
http_network_session_params_.quic_connection_options; http_network_session_params_.quic_connection_options;
network_session_params.ssl_session_cache_shard = network_session_params.ssl_session_cache_shard =
......
...@@ -87,6 +87,10 @@ class NET_EXPORT URLRequestContextBuilder { ...@@ -87,6 +87,10 @@ class NET_EXPORT URLRequestContextBuilder {
std::string trusted_spdy_proxy; std::string trusted_spdy_proxy;
bool use_alternative_services; bool use_alternative_services;
bool enable_quic; bool enable_quic;
bool quic_store_server_configs_in_properties;
bool quic_delay_tcp_race;
int quic_max_number_of_lossy_connections;
float quic_packet_loss_threshold;
QuicTagVector quic_connection_options; QuicTagVector quic_connection_options;
std::string ssl_session_cache_shard; std::string ssl_session_cache_shard;
}; };
...@@ -198,6 +202,27 @@ class NET_EXPORT URLRequestContextBuilder { ...@@ -198,6 +202,27 @@ class NET_EXPORT URLRequestContextBuilder {
ssl_session_cache_shard; ssl_session_cache_shard;
} }
void set_quic_store_server_configs_in_properties(
bool quic_store_server_configs_in_properties) {
http_network_session_params_.quic_store_server_configs_in_properties =
quic_store_server_configs_in_properties;
}
void set_quic_delay_tcp_race(bool quic_delay_tcp_race) {
http_network_session_params_.quic_delay_tcp_race = quic_delay_tcp_race;
}
void set_quic_max_number_of_lossy_connections(
int quic_max_number_of_lossy_connections) {
http_network_session_params_.quic_max_number_of_lossy_connections =
quic_max_number_of_lossy_connections;
}
void set_quic_packet_loss_threshold(float quic_packet_loss_threshold) {
http_network_session_params_.quic_packet_loss_threshold =
quic_packet_loss_threshold;
}
void set_throttling_enabled(bool throttling_enabled) { void set_throttling_enabled(bool throttling_enabled) {
throttling_enabled_ = throttling_enabled; throttling_enabled_ = throttling_enabled;
} }
......
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