Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: components/cronet/android/url_request_context_adapter.cc

Issue 544223003: Add SetSupportsQuic method to explicitly specify server that supports QUIC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable Quic test. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cronet/android/url_request_context_adapter.h" 5 #include "components/cronet/android/url_request_context_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "components/cronet/url_request_context_config.h" 10 #include "components/cronet/url_request_context_config.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/net_log_logger.h" 12 #include "net/base/net_log_logger.h"
13 #include "net/cert/cert_verifier.h" 13 #include "net/cert/cert_verifier.h"
14 #include "net/http/http_auth_handler_factory.h" 14 #include "net/http/http_auth_handler_factory.h"
15 #include "net/http/http_network_layer.h" 15 #include "net/http/http_network_layer.h"
16 #include "net/http/http_server_properties_impl.h" 16 #include "net/http/http_server_properties.h"
17 #include "net/proxy/proxy_config_service_fixed.h" 17 #include "net/proxy/proxy_config_service_fixed.h"
18 #include "net/proxy/proxy_service.h" 18 #include "net/proxy/proxy_service.h"
19 #include "net/ssl/ssl_config_service_defaults.h" 19 #include "net/ssl/ssl_config_service_defaults.h"
20 #include "net/url_request/static_http_user_agent_settings.h" 20 #include "net/url_request/static_http_user_agent_settings.h"
21 #include "net/url_request/url_request_context_builder.h" 21 #include "net/url_request/url_request_context_builder.h"
22 #include "net/url_request/url_request_context_storage.h" 22 #include "net/url_request/url_request_context_storage.h"
23 #include "net/url_request/url_request_job_factory_impl.h" 23 #include "net/url_request/url_request_job_factory_impl.h"
24 24
25 namespace { 25 namespace {
26 26
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 scoped_ptr<URLRequestContextConfig> config) { 137 scoped_ptr<URLRequestContextConfig> config) {
138 // TODO(mmenke): Add method to have the builder enable SPDY. 138 // TODO(mmenke): Add method to have the builder enable SPDY.
139 net::URLRequestContextBuilder context_builder; 139 net::URLRequestContextBuilder context_builder;
140 context_builder.set_network_delegate(new BasicNetworkDelegate()); 140 context_builder.set_network_delegate(new BasicNetworkDelegate());
141 context_builder.set_proxy_config_service( 141 context_builder.set_proxy_config_service(
142 new net::ProxyConfigServiceFixed(net::ProxyConfig())); 142 new net::ProxyConfigServiceFixed(net::ProxyConfig()));
143 config->ConfigureURLRequestContextBuilder(&context_builder); 143 config->ConfigureURLRequestContextBuilder(&context_builder);
144 144
145 context_.reset(context_builder.Build()); 145 context_.reset(context_builder.Build());
146 146
147 // Currently (circa M39) enabling QUIC requires setting probability threshold.
148 if (config->enable_quic) {
149 context_->http_server_properties()
150 ->SetAlternateProtocolProbabilityThreshold(1.0f);
151 for (size_t hint = 0; hint < config->quic_hints.size(); ++hint) {
152 const URLRequestContextConfig::QuicHint& quic_hint =
153 *config->quic_hints[hint];
154 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.
155 if (quic_hint_host.IsEmpty()) {
156 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.
157 continue;
158 }
159
160 if (quic_hint.alternate_port <= std::numeric_limits<uint16>::min() ||
161 quic_hint.alternate_port > std::numeric_limits<uint16>::max()) {
162 LOG(ERROR) << "Invalid QUIC hint alternate port: "
163 << quic_hint.alternate_port;
164 continue;
165 }
166
167 context_->http_server_properties()->SetAlternateProtocol(
168 quic_hint_host,
169 static_cast<uint16>(quic_hint.alternate_port),
170 net::AlternateProtocol::QUIC,
171 1.0f);
172 }
173 }
174
147 if (VLOG_IS_ON(2)) { 175 if (VLOG_IS_ON(2)) {
148 net_log_observer_.reset(new NetLogObserver()); 176 net_log_observer_.reset(new NetLogObserver());
149 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), 177 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(),
150 net::NetLog::LOG_ALL_BUT_BYTES); 178 net::NetLog::LOG_ALL_BUT_BYTES);
151 } 179 }
152 180
153 delegate_->OnContextInitialized(this); 181 delegate_->OnContextInitialized(this);
154 } 182 }
155 183
156 URLRequestContextAdapter::~URLRequestContextAdapter() { 184 URLRequestContextAdapter::~URLRequestContextAdapter() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 net_log_logger_.reset(); 228 net_log_logger_.reset();
201 } 229 }
202 } 230 }
203 231
204 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { 232 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
205 VLOG(2) << "Net log entry: type=" << entry.type() 233 VLOG(2) << "Net log entry: type=" << entry.type()
206 << ", source=" << entry.source().type << ", phase=" << entry.phase(); 234 << ", source=" << entry.source().type << ", phase=" << entry.phase();
207 } 235 }
208 236
209 } // namespace cronet 237 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698