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..00de9fe2bafeda454661f7aec5bf37ab2cd6dbfb 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. |
mmenke
2014/09/10 18:21:27
Great! I suggest keeping this one and getting rid
mef
2014/09/10 20:18:48
Acknowledged.
|
+ 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() || |
mmenke
2014/09/10 18:21:27
port 0 is also invalid, no?
mef
2014/09/10 20:18:48
Done.
|
+ quic_hint.alternate_port > std::numeric_limits<uint16>::max()) { |
+ LOG(ERROR) << "Invalid QUIC hint: " << quic_hint.server; |
+ continue; |
+ } |
+ |
+ net::HostPortPair quic_hint_host(server.HostNoBrackets(), |
+ server.EffectiveIntPort()); |
+ DCHECK(!quic_hint_host.IsEmpty()); |
mmenke
2014/09/10 18:21:27
Why DCHECK on empty hosts, but LOG(ERROR) on missi
mef
2014/09/10 20:18:48
Done.
|
+ 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(); |