| Index: components/cronet/android/url_request_context_adapter.cc
|
| diff --git a/components/cronet/android/url_request_context_adapter.cc b/components/cronet/android/url_request_context_adapter.cc
|
| index 0feb0f13e4ad825768ca041f4665061cfcafeba8..7035471596321d5995fae7016f5128c26464e40d 100644
|
| --- a/components/cronet/android/url_request_context_adapter.cc
|
| +++ b/components/cronet/android/url_request_context_adapter.cc
|
| @@ -13,7 +13,7 @@
|
| #include "net/cert/cert_verifier.h"
|
| #include "net/http/http_auth_handler_factory.h"
|
| #include "net/http/http_network_layer.h"
|
| -#include "net/http/http_server_properties_impl.h"
|
| +#include "net/http/http_server_properties.h"
|
| #include "net/proxy/proxy_config_service_fixed.h"
|
| #include "net/proxy/proxy_service.h"
|
| #include "net/ssl/ssl_config_service_defaults.h"
|
| @@ -143,6 +143,38 @@ void URLRequestContextAdapter::InitializeURLRequestContext(
|
| config->ConfigureURLRequestContextBuilder(&context_builder);
|
|
|
| context_.reset(context_builder.Build());
|
| + DCHECK(!config->enable_quic || !config->quic_hints.empty());
|
| +
|
| + // Currently (circa M39) enabling QUIC requires setting probability threshold.
|
| + if (config->enable_quic) {
|
| + context_->http_server_properties()
|
| + ->SetAlternateProtocolProbabilityThreshold(1.0f);
|
| + if (!config->quic_hints.empty()) {
|
| + for (size_t hint = 0; hint < config->quic_hints.size(); ++hint) {
|
| + const URLRequestContextConfig::QuicHint& quic_hint =
|
| + *config->quic_hints[hint];
|
| + GURL server(quic_hint.server);
|
| + if (!server.is_valid() ||
|
| + quic_hint.alternate_port < std::numeric_limits<uint16>::min() ||
|
| + quic_hint.alternate_port > std::numeric_limits<uint16>::max()) {
|
| + LOG(ERROR) << "Invalid QUIC hint: " << quic_hint.server;
|
| + DCHECK(0);
|
| + continue;
|
| + }
|
| +
|
| + net::HostPortPair quic_hint_host(server.HostNoBrackets(),
|
| + server.EffectiveIntPort());
|
| + DCHECK(!quic_hint_host.IsEmpty());
|
| + context_->http_server_properties()->SetAlternateProtocol(
|
| + quic_hint_host,
|
| + static_cast<uint16>(quic_hint.alternate_port),
|
| + net::AlternateProtocol::QUIC,
|
| + 1.0f);
|
| + DCHECK(context_->http_server_properties()->HasAlternateProtocol(
|
| + quic_hint_host));
|
| + }
|
| + }
|
| + }
|
|
|
| if (VLOG_IS_ON(2)) {
|
| net_log_observer_.reset(new NetLogObserver());
|
| @@ -201,6 +233,19 @@ void URLRequestContextAdapter::StopNetLog() {
|
| }
|
| }
|
|
|
| +void URLRequestContextAdapter::SetQuicHint(const net::HostPortPair& server,
|
| + uint16 alternate_port,
|
| + double probability) {
|
| + GetNetworkTaskRunner()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&net::HttpServerProperties::SetAlternateProtocol,
|
| + context_->http_server_properties(),
|
| + server,
|
| + alternate_port,
|
| + net::AlternateProtocol::QUIC,
|
| + probability));
|
| +}
|
| +
|
| void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
|
| VLOG(2) << "Net log entry: type=" << entry.type()
|
| << ", source=" << entry.source().type << ", phase=" << entry.phase();
|
|
|