| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 websocket_handshake_stream_create_helper, | 99 websocket_handshake_stream_create_helper, |
| 100 net_log, stream_type); | 100 net_log, stream_type); |
| 101 HostPortPair server = HostPortPair::FromURL(request_info.url); | 101 HostPortPair server = HostPortPair::FromURL(request_info.url); |
| 102 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); | 102 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
| 103 | 103 |
| 104 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 104 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 105 proxy_ssl_config, server, origin_url, net_log.net_log()); | 105 proxy_ssl_config, server, origin_url, net_log.net_log()); |
| 106 request->AttachJob(job); | 106 request->AttachJob(job); |
| 107 | 107 |
| 108 const AlternativeService alternative_service = | 108 const AlternativeService alternative_service = |
| 109 GetAlternativeServiceFor(request_info, delegate); | 109 GetAlternativeServiceFor(request_info, delegate, stream_type); |
| 110 | 110 |
| 111 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 111 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 112 // Never share connection with other jobs for FTP requests. | 112 // Never share connection with other jobs for FTP requests. |
| 113 DVLOG(1) << "Selected alternative service (host: " | 113 DVLOG(1) << "Selected alternative service (host: " |
| 114 << alternative_service.host_port_pair().host() | 114 << alternative_service.host_port_pair().host() |
| 115 << " port: " << alternative_service.host_port_pair().port() << ")"; | 115 << " port: " << alternative_service.host_port_pair().port() << ")"; |
| 116 | 116 |
| 117 DCHECK(!request_info.url.SchemeIs("ftp")); | 117 DCHECK(!request_info.url.SchemeIs("ftp")); |
| 118 HostPortPair server = alternative_service.host_port_pair(); | 118 HostPortPair server = alternative_service.host_port_pair(); |
| 119 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); | 119 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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 const SSLConfig& server_ssl_config, |
| 145 const SSLConfig& proxy_ssl_config) { | 145 const SSLConfig& proxy_ssl_config) { |
| 146 DCHECK(!for_websockets_); | 146 DCHECK(!for_websockets_); |
| 147 AlternativeService alternative_service = | 147 AlternativeService alternative_service = GetAlternativeServiceFor( |
| 148 GetAlternativeServiceFor(request_info, nullptr); | 148 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); |
| 149 HostPortPair server; | 149 HostPortPair server; |
| 150 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 150 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 151 server = alternative_service.host_port_pair(); | 151 server = alternative_service.host_port_pair(); |
| 152 if (session_->params().quic_disable_preconnect_if_0rtt && | 152 if (session_->params().quic_disable_preconnect_if_0rtt && |
| 153 alternative_service.protocol == QUIC && | 153 alternative_service.protocol == QUIC && |
| 154 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( | 154 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( |
| 155 alternative_service.host_port_pair(), request_info.privacy_mode))) { | 155 alternative_service.host_port_pair(), request_info.privacy_mode))) { |
| 156 return; | 156 return; |
| 157 } | 157 } |
| 158 } else { | 158 } else { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 preconnect_job_set_.insert(job); | 169 preconnect_job_set_.insert(job); |
| 170 job->Preconnect(num_streams); | 170 job->Preconnect(num_streams); |
| 171 } | 171 } |
| 172 | 172 |
| 173 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 173 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 174 return session_->params().host_mapping_rules; | 174 return session_->params().host_mapping_rules; |
| 175 } | 175 } |
| 176 | 176 |
| 177 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( | 177 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( |
| 178 const HttpRequestInfo& request_info, | 178 const HttpRequestInfo& request_info, |
| 179 HttpStreamRequest::Delegate* delegate) { | 179 HttpStreamRequest::Delegate* delegate, |
| 180 HttpStreamRequest::StreamType stream_type) { |
| 180 GURL original_url = request_info.url; | 181 GURL original_url = request_info.url; |
| 181 | 182 |
| 182 if (original_url.SchemeIs("ftp")) | 183 if (original_url.SchemeIs("ftp")) |
| 183 return AlternativeService(); | 184 return AlternativeService(); |
| 184 | 185 |
| 185 HostPortPair origin = HostPortPair::FromURL(original_url); | 186 HostPortPair origin = HostPortPair::FromURL(original_url); |
| 186 HttpServerProperties& http_server_properties = | 187 HttpServerProperties& http_server_properties = |
| 187 *session_->http_server_properties(); | 188 *session_->http_server_properties(); |
| 188 const AlternativeServiceVector alternative_service_vector = | 189 const AlternativeServiceVector alternative_service_vector = |
| 189 http_server_properties.GetAlternativeServices(origin); | 190 http_server_properties.GetAlternativeServices(origin); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 UNINITIALIZED_ALTERNATE_PROTOCOL) | 237 UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 237 first_alternative_service = alternative_service; | 238 first_alternative_service = alternative_service; |
| 238 continue; | 239 continue; |
| 239 } | 240 } |
| 240 | 241 |
| 241 DCHECK_EQ(QUIC, alternative_service.protocol); | 242 DCHECK_EQ(QUIC, alternative_service.protocol); |
| 242 quic_all_broken = false; | 243 quic_all_broken = false; |
| 243 if (!session_->params().enable_quic) | 244 if (!session_->params().enable_quic) |
| 244 continue; | 245 continue; |
| 245 | 246 |
| 247 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && |
| 248 session_->params().quic_disable_bidirectional_streams) { |
| 249 continue; |
| 250 } |
| 251 |
| 246 if (session_->quic_stream_factory()->IsQuicDisabled(origin.port())) | 252 if (session_->quic_stream_factory()->IsQuicDisabled(origin.port())) |
| 247 continue; | 253 continue; |
| 248 | 254 |
| 249 if (!original_url.SchemeIs("https")) | 255 if (!original_url.SchemeIs("https")) |
| 250 continue; | 256 continue; |
| 251 | 257 |
| 252 // Check whether there's an existing session to use for this QUIC Alt-Svc. | 258 // Check whether there's an existing session to use for this QUIC Alt-Svc. |
| 253 HostPortPair destination = alternative_service.host_port_pair(); | 259 HostPortPair destination = alternative_service.host_port_pair(); |
| 254 std::string origin_host = | 260 std::string origin_host = |
| 255 ApplyHostMappingRules(request_info.url, &destination).host(); | 261 ApplyHostMappingRules(request_info.url, &destination).host(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return true; | 358 return true; |
| 353 | 359 |
| 354 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) | 360 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
| 355 return true; | 361 return true; |
| 356 | 362 |
| 357 return ContainsKey(session_->params().quic_host_whitelist, | 363 return ContainsKey(session_->params().quic_host_whitelist, |
| 358 base::ToLowerASCII(host)); | 364 base::ToLowerASCII(host)); |
| 359 } | 365 } |
| 360 | 366 |
| 361 } // namespace net | 367 } // namespace net |
| OLD | NEW |