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 4552f10118d45760ec9738c9bcd66e99277f4ad6..ac767ec6962cbecb741a58c20c99cf41eebc2c8e 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,34 @@ 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); |
+ for (size_t hint = 0; hint < config->quic_hints.size(); ++hint) { |
+ const URLRequestContextConfig::QuicHint& quic_hint = |
+ *config->quic_hints[hint]; |
+ net::HostPortPair quic_hint_host(quic_hint.host, quic_hint.port); |
mmenke
2014/09/16 01:51:38
optional nit: Suggest calling this quic_hint_host
mef
2014/09/16 08:44:14
Done.
|
+ if (quic_hint_host.IsEmpty()) { |
+ LOG(ERROR) << "Invalid QUIC hint host: " << quic_hint.host; |
mmenke
2014/09/16 01:51:38
This line seems a bit silly, seeing as IsEmpty onl
mef
2014/09/16 08:44:14
Done.
|
+ continue; |
+ } |
+ |
+ if (quic_hint.alternate_port <= std::numeric_limits<uint16>::min() || |
+ quic_hint.alternate_port > std::numeric_limits<uint16>::max()) { |
+ LOG(ERROR) << "Invalid QUIC hint alternate port: " |
+ << quic_hint.alternate_port; |
+ continue; |
+ } |
+ |
+ context_->http_server_properties()->SetAlternateProtocol( |
+ quic_hint_host, |
+ static_cast<uint16>(quic_hint.alternate_port), |
+ net::AlternateProtocol::QUIC, |
+ 1.0f); |
+ } |
+ } |
+ |
if (VLOG_IS_ON(2)) { |
net_log_observer_.reset(new NetLogObserver()); |
context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |