| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 // Even if |alternative_job| has already finished, it will not have notified | 134 // Even if |alternative_job| has already finished, it will not have notified |
| 135 // the request yet, since we defer that to the next iteration of the | 135 // the request yet, since we defer that to the next iteration of the |
| 136 // MessageLoop, so starting |job| is always safe. | 136 // MessageLoop, so starting |job| is always safe. |
| 137 job->Start(request); | 137 job->Start(request); |
| 138 return request; | 138 return request; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void HttpStreamFactoryImpl::PreconnectStreams( | 141 void HttpStreamFactoryImpl::PreconnectStreams( |
| 142 int num_streams, | 142 int num_streams, |
| 143 const HttpRequestInfo& request_info, | 143 const HttpRequestInfo& request_info) { |
| 144 const SSLConfig& server_ssl_config, | 144 SSLConfig ssl_config; |
| 145 const SSLConfig& proxy_ssl_config) { | 145 session_->GetSSLConfig(request_info, &ssl_config); |
| 146 // All preconnects should perform EV certificate verification. |
| 147 ssl_config.verify_ev_cert = true; |
| 148 |
| 146 DCHECK(!for_websockets_); | 149 DCHECK(!for_websockets_); |
| 147 AlternativeService alternative_service = GetAlternativeServiceFor( | 150 AlternativeService alternative_service = GetAlternativeServiceFor( |
| 148 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); | 151 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); |
| 149 HostPortPair server; | 152 HostPortPair server; |
| 150 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 153 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 151 server = alternative_service.host_port_pair(); | 154 server = alternative_service.host_port_pair(); |
| 152 if (session_->params().quic_disable_preconnect_if_0rtt && | 155 if (session_->params().quic_disable_preconnect_if_0rtt && |
| 153 alternative_service.protocol == QUIC && | 156 alternative_service.protocol == QUIC && |
| 154 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( | 157 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( |
| 155 alternative_service.host_port_pair(), request_info.privacy_mode))) { | 158 alternative_service.host_port_pair(), request_info.privacy_mode))) { |
| 156 return; | 159 return; |
| 157 } | 160 } |
| 158 } else { | 161 } else { |
| 159 server = HostPortPair::FromURL(request_info.url); | 162 server = HostPortPair::FromURL(request_info.url); |
| 160 } | 163 } |
| 161 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); | 164 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
| 162 // Due to how the socket pools handle priorities and idle sockets, only IDLE | 165 // Due to how the socket pools handle priorities and idle sockets, only IDLE |
| 163 // priority currently makes sense for preconnects. The priority for | 166 // priority currently makes sense for preconnects. The priority for |
| 164 // preconnects is currently ignored (see RequestSocketsForPool()), but could | 167 // preconnects is currently ignored (see RequestSocketsForPool()), but could |
| 165 // be used at some point for proxy resolution or something. | 168 // be used at some point for proxy resolution or something. |
| 166 Job* job = new Job(this, session_, request_info, IDLE, server_ssl_config, | 169 Job* job = |
| 167 proxy_ssl_config, server, origin_url, alternative_service, | 170 new Job(this, session_, request_info, IDLE, ssl_config, ssl_config, |
| 168 session_->net_log()); | 171 server, origin_url, alternative_service, session_->net_log()); |
| 169 preconnect_job_set_.insert(job); | 172 preconnect_job_set_.insert(job); |
| 170 job->Preconnect(num_streams); | 173 job->Preconnect(num_streams); |
| 171 } | 174 } |
| 172 | 175 |
| 173 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 176 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 174 return session_->params().host_mapping_rules; | 177 return session_->params().host_mapping_rules; |
| 175 } | 178 } |
| 176 | 179 |
| 177 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( | 180 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( |
| 178 const HttpRequestInfo& request_info, | 181 const HttpRequestInfo& request_info, |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return true; | 361 return true; |
| 359 | 362 |
| 360 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) | 363 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
| 361 return true; | 364 return true; |
| 362 | 365 |
| 363 return ContainsKey(session_->params().quic_host_whitelist, | 366 return ContainsKey(session_->params().quic_host_whitelist, |
| 364 base::ToLowerASCII(host)); | 367 base::ToLowerASCII(host)); |
| 365 } | 368 } |
| 366 | 369 |
| 367 } // namespace net | 370 } // namespace net |
| OLD | NEW |