OLD | NEW |
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/file_util.h" | 8 #include "base/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 Loading... |
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 double quic_threshold = config->enable_quic ? 1.0f : 0.0f; |
| 149 context_->http_server_properties()->SetAlternateProtocolProbabilityThreshold( |
| 150 quic_threshold); |
| 151 |
147 if (VLOG_IS_ON(2)) { | 152 if (VLOG_IS_ON(2)) { |
148 net_log_observer_.reset(new NetLogObserver()); | 153 net_log_observer_.reset(new NetLogObserver()); |
149 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), | 154 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |
150 net::NetLog::LOG_ALL_BUT_BYTES); | 155 net::NetLog::LOG_ALL_BUT_BYTES); |
151 } | 156 } |
152 | 157 |
153 delegate_->OnContextInitialized(this); | 158 delegate_->OnContextInitialized(this); |
154 } | 159 } |
155 | 160 |
156 URLRequestContextAdapter::~URLRequestContextAdapter() { | 161 URLRequestContextAdapter::~URLRequestContextAdapter() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 net_log_logger_->StartObserving(context_->net_log()); | 199 net_log_logger_->StartObserving(context_->net_log()); |
195 } | 200 } |
196 | 201 |
197 void URLRequestContextAdapter::StopNetLog() { | 202 void URLRequestContextAdapter::StopNetLog() { |
198 if (net_log_logger_) { | 203 if (net_log_logger_) { |
199 net_log_logger_->StopObserving(); | 204 net_log_logger_->StopObserving(); |
200 net_log_logger_.reset(); | 205 net_log_logger_.reset(); |
201 } | 206 } |
202 } | 207 } |
203 | 208 |
| 209 void URLRequestContextAdapter::SetSupportsQuic(const net::HostPortPair& server, |
| 210 uint16 alternate_port, |
| 211 double probability) { |
| 212 GetNetworkTaskRunner()->PostTask( |
| 213 FROM_HERE, |
| 214 base::Bind(&net::HttpServerProperties::SetAlternateProtocol, |
| 215 context_->http_server_properties(), |
| 216 server, |
| 217 alternate_port, |
| 218 net::AlternateProtocol::QUIC, |
| 219 probability)); |
| 220 } |
| 221 |
204 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 222 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
205 VLOG(2) << "Net log entry: type=" << entry.type() | 223 VLOG(2) << "Net log entry: type=" << entry.type() |
206 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 224 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
207 } | 225 } |
208 | 226 |
209 } // namespace cronet | 227 } // namespace cronet |
OLD | NEW |