| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "components/cronet/url_request_context_config.h" | 13 #include "components/cronet/url_request_context_config.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_log_logger.h" | 15 #include "net/base/net_log_logger.h" |
| 16 #include "net/base/net_util.h" |
| 16 #include "net/cert/cert_verifier.h" | 17 #include "net/cert/cert_verifier.h" |
| 17 #include "net/http/http_auth_handler_factory.h" | 18 #include "net/http/http_auth_handler_factory.h" |
| 18 #include "net/http/http_network_layer.h" | 19 #include "net/http/http_network_layer.h" |
| 19 #include "net/http/http_server_properties.h" | 20 #include "net/http/http_server_properties.h" |
| 20 #include "net/proxy/proxy_service.h" | 21 #include "net/proxy/proxy_service.h" |
| 21 #include "net/ssl/ssl_config_service_defaults.h" | 22 #include "net/ssl/ssl_config_service_defaults.h" |
| 22 #include "net/url_request/static_http_user_agent_settings.h" | 23 #include "net/url_request/static_http_user_agent_settings.h" |
| 23 #include "net/url_request/url_request_context_builder.h" | 24 #include "net/url_request/url_request_context_builder.h" |
| 24 #include "net/url_request/url_request_context_storage.h" | 25 #include "net/url_request/url_request_context_storage.h" |
| 25 #include "net/url_request/url_request_job_factory_impl.h" | 26 #include "net/url_request/url_request_job_factory_impl.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 context_->http_server_properties() | 167 context_->http_server_properties() |
| 167 ->SetAlternateProtocolProbabilityThreshold(0.0f); | 168 ->SetAlternateProtocolProbabilityThreshold(0.0f); |
| 168 for (size_t hint = 0; hint < config_->quic_hints.size(); ++hint) { | 169 for (size_t hint = 0; hint < config_->quic_hints.size(); ++hint) { |
| 169 const URLRequestContextConfig::QuicHint& quic_hint = | 170 const URLRequestContextConfig::QuicHint& quic_hint = |
| 170 *config_->quic_hints[hint]; | 171 *config_->quic_hints[hint]; |
| 171 if (quic_hint.host.empty()) { | 172 if (quic_hint.host.empty()) { |
| 172 LOG(ERROR) << "Empty QUIC hint host: " << quic_hint.host; | 173 LOG(ERROR) << "Empty QUIC hint host: " << quic_hint.host; |
| 173 continue; | 174 continue; |
| 174 } | 175 } |
| 175 | 176 |
| 177 url::CanonHostInfo host_info; |
| 178 std::string canon_host(net::CanonicalizeHost(quic_hint.host, &host_info)); |
| 179 if (!host_info.IsIPAddress() && |
| 180 !net::IsCanonicalizedHostCompliant(canon_host)) { |
| 181 LOG(ERROR) << "Invalid QUIC hint host: " << quic_hint.host; |
| 182 continue; |
| 183 } |
| 184 |
| 176 if (quic_hint.port <= std::numeric_limits<uint16>::min() || | 185 if (quic_hint.port <= std::numeric_limits<uint16>::min() || |
| 177 quic_hint.port > std::numeric_limits<uint16>::max()) { | 186 quic_hint.port > std::numeric_limits<uint16>::max()) { |
| 178 LOG(ERROR) << "Invalid QUIC hint port: " | 187 LOG(ERROR) << "Invalid QUIC hint port: " |
| 179 << quic_hint.port; | 188 << quic_hint.port; |
| 180 continue; | 189 continue; |
| 181 } | 190 } |
| 182 | 191 |
| 183 if (quic_hint.alternate_port <= std::numeric_limits<uint16>::min() || | 192 if (quic_hint.alternate_port <= std::numeric_limits<uint16>::min() || |
| 184 quic_hint.alternate_port > std::numeric_limits<uint16>::max()) { | 193 quic_hint.alternate_port > std::numeric_limits<uint16>::max()) { |
| 185 LOG(ERROR) << "Invalid QUIC hint alternate port: " | 194 LOG(ERROR) << "Invalid QUIC hint alternate port: " |
| 186 << quic_hint.alternate_port; | 195 << quic_hint.alternate_port; |
| 187 continue; | 196 continue; |
| 188 } | 197 } |
| 189 | 198 |
| 190 net::HostPortPair quic_hint_host_port_pair(quic_hint.host, | 199 net::HostPortPair quic_hint_host_port_pair(canon_host, |
| 191 quic_hint.port); | 200 quic_hint.port); |
| 192 context_->http_server_properties()->SetAlternateProtocol( | 201 context_->http_server_properties()->SetAlternateProtocol( |
| 193 quic_hint_host_port_pair, | 202 quic_hint_host_port_pair, |
| 194 static_cast<uint16>(quic_hint.alternate_port), | 203 static_cast<uint16>(quic_hint.alternate_port), |
| 195 net::AlternateProtocol::QUIC, | 204 net::AlternateProtocol::QUIC, |
| 196 1.0f); | 205 1.0f); |
| 197 } | 206 } |
| 198 } | 207 } |
| 199 config_.reset(NULL); | 208 config_.reset(NULL); |
| 200 | 209 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 net_log_logger_.reset(); | 307 net_log_logger_.reset(); |
| 299 } | 308 } |
| 300 } | 309 } |
| 301 | 310 |
| 302 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 311 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 303 VLOG(2) << "Net log entry: type=" << entry.type() | 312 VLOG(2) << "Net log entry: type=" << entry.type() |
| 304 << ", source=" << entry.source().type << ", phase=" << entry.phase(); | 313 << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
| 305 } | 314 } |
| 306 | 315 |
| 307 } // namespace cronet | 316 } // namespace cronet |
| OLD | NEW |