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..ef86c1c1d432c781455c576a1ffa1744f3784305 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); |
+ if (!config->quic_hints.empty()) { |
Ryan Hamilton
2014/09/10 20:58:19
I'm not sure that this guard saves you anything...
mef
2014/09/12 19:44:33
Done.
|
+ for (size_t hint = 0; hint < config->quic_hints.size(); ++hint) { |
+ const URLRequestContextConfig::QuicHint& quic_hint = |
+ *config->quic_hints[hint]; |
+ GURL quic_hint_server(quic_hint.server); |
+ net::HostPortPair quic_hint_host(quic_hint_server.HostNoBrackets(), |
+ quic_hint_server.EffectiveIntPort()); |
Ryan Hamilton
2014/09/10 20:58:19
If you change the types of the QuicHint members, I
mef
2014/09/12 19:44:33
As Matt has mention this is de-serialized from JSO
|
+ if (!quic_hint_server.is_valid() || |
+ quic_hint.alternate_port <= std::numeric_limits<uint16>::min() || |
+ quic_hint.alternate_port > std::numeric_limits<uint16>::max() || |
+ quic_hint_host.IsEmpty()) { |
+ LOG(ERROR) << "Invalid QUIC hint: " << quic_hint.server; |
+ continue; |
+ } |
Ryan Hamilton
2014/09/10 20:58:19
Does SetAlternateProtocol perform similar checks?
mef
2014/09/12 19:44:33
Umm, SetAlternateProtocol just uses host_port_pair
|
+ |
+ 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(), |
@@ -201,6 +229,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(); |