Chromium Code Reviews| 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..70c66dab7122fa9f2e59f9b8f755aab144010633 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" |
| @@ -144,6 +144,31 @@ void URLRequestContextAdapter::InitializeURLRequestContext( |
| context_.reset(context_builder.Build()); |
| + // 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; |
| + continue; |
| + } |
| + |
| + context_->http_server_properties()->SetAlternateProtocol( |
| + net::HostPortPair::FromURL(server), |
| + static_cast<uint16>(quic_hint.alternate_port), |
| + net::AlternateProtocol::QUIC, |
| + 0.5f); |
| + } |
| + } |
| + } |
| + |
| if (VLOG_IS_ON(2)) { |
| net_log_observer_.reset(new NetLogObserver()); |
| context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |
| @@ -201,6 +226,19 @@ void URLRequestContextAdapter::StopNetLog() { |
| } |
| } |
| +void URLRequestContextAdapter::SetQuicHint(const net::HostPortPair& server, |
|
mmenke
2014/09/09 14:53:35
Do we really need multiple ways of setting per-ser
mef
2014/09/10 16:48:18
Probably not, I'll be happy to remove it.
|
| + 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(); |