| 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" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "net/base/load_flags.h" |
| 12 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 14 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
| 15 #include "net/http/http_server_properties.h" | 16 #include "net/http/http_server_properties.h" |
| 16 #include "net/http/http_stream_factory_impl_job.h" | 17 #include "net/http/http_stream_factory_impl_job.h" |
| 17 #include "net/http/http_stream_factory_impl_request.h" | 18 #include "net/http/http_stream_factory_impl_request.h" |
| 18 #include "net/spdy/spdy_http_stream.h" | 19 #include "net/spdy/spdy_http_stream.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 WebSocketHandshakeStreamBase::CreateHelper* | 100 WebSocketHandshakeStreamBase::CreateHelper* |
| 100 websocket_handshake_stream_create_helper, | 101 websocket_handshake_stream_create_helper, |
| 101 const BoundNetLog& net_log) { | 102 const BoundNetLog& net_log) { |
| 102 Request* request = new Request(request_info.url, | 103 Request* request = new Request(request_info.url, |
| 103 this, | 104 this, |
| 104 delegate, | 105 delegate, |
| 105 websocket_handshake_stream_create_helper, | 106 websocket_handshake_stream_create_helper, |
| 106 net_log); | 107 net_log); |
| 107 | 108 |
| 108 GURL alternate_url; | 109 GURL alternate_url; |
| 109 AlternateProtocolInfo alternate = | 110 |
| 110 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); | 111 AlternateProtocolInfo alternate = GetAlternateProtocolRequestFor( |
| 112 request_info.url, request_info.load_flags, &alternate_url); |
| 113 |
| 111 Job* alternate_job = NULL; | 114 Job* alternate_job = NULL; |
| 112 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 115 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 113 // Never share connection with other jobs for FTP requests. | 116 // Never share connection with other jobs for FTP requests. |
| 114 DCHECK(!request_info.url.SchemeIs("ftp")); | 117 DCHECK(!request_info.url.SchemeIs("ftp")); |
| 115 | 118 |
| 116 HttpRequestInfo alternate_request_info = request_info; | 119 HttpRequestInfo alternate_request_info = request_info; |
| 117 alternate_request_info.url = alternate_url; | 120 alternate_request_info.url = alternate_url; |
| 118 alternate_job = | 121 alternate_job = |
| 119 new Job(this, session_, alternate_request_info, priority, | 122 new Job(this, session_, alternate_request_info, priority, |
| 120 server_ssl_config, proxy_ssl_config, net_log.net_log()); | 123 server_ssl_config, proxy_ssl_config, net_log.net_log()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 143 } | 146 } |
| 144 | 147 |
| 145 void HttpStreamFactoryImpl::PreconnectStreams( | 148 void HttpStreamFactoryImpl::PreconnectStreams( |
| 146 int num_streams, | 149 int num_streams, |
| 147 const HttpRequestInfo& request_info, | 150 const HttpRequestInfo& request_info, |
| 148 RequestPriority priority, | 151 RequestPriority priority, |
| 149 const SSLConfig& server_ssl_config, | 152 const SSLConfig& server_ssl_config, |
| 150 const SSLConfig& proxy_ssl_config) { | 153 const SSLConfig& proxy_ssl_config) { |
| 151 DCHECK(!for_websockets_); | 154 DCHECK(!for_websockets_); |
| 152 GURL alternate_url; | 155 GURL alternate_url; |
| 153 AlternateProtocolInfo alternate = | 156 AlternateProtocolInfo alternate = GetAlternateProtocolRequestFor( |
| 154 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); | 157 request_info.url, request_info.load_flags, &alternate_url); |
| 158 |
| 155 Job* job = NULL; | 159 Job* job = NULL; |
| 156 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 160 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 157 HttpRequestInfo alternate_request_info = request_info; | 161 HttpRequestInfo alternate_request_info = request_info; |
| 158 alternate_request_info.url = alternate_url; | 162 alternate_request_info.url = alternate_url; |
| 159 job = new Job(this, session_, alternate_request_info, priority, | 163 job = new Job(this, session_, alternate_request_info, priority, |
| 160 server_ssl_config, proxy_ssl_config, session_->net_log()); | 164 server_ssl_config, proxy_ssl_config, session_->net_log()); |
| 161 job->MarkAsAlternate(request_info.url, alternate); | 165 job->MarkAsAlternate(request_info.url, alternate); |
| 162 } else { | 166 } else { |
| 163 job = new Job(this, session_, request_info, priority, | 167 job = new Job(this, session_, request_info, priority, |
| 164 server_ssl_config, proxy_ssl_config, session_->net_log()); | 168 server_ssl_config, proxy_ssl_config, session_->net_log()); |
| 165 } | 169 } |
| 166 preconnect_job_set_.insert(job); | 170 preconnect_job_set_.insert(job); |
| 167 job->Preconnect(num_streams); | 171 job->Preconnect(num_streams); |
| 168 } | 172 } |
| 169 | 173 |
| 170 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 174 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 171 return session_->params().host_mapping_rules; | 175 return session_->params().host_mapping_rules; |
| 172 } | 176 } |
| 173 | 177 |
| 174 AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( | 178 AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( |
| 175 const GURL& original_url, | 179 const GURL& original_url, |
| 180 int load_flags, |
| 176 GURL* alternate_url) { | 181 GURL* alternate_url) { |
| 177 const AlternateProtocolInfo kNoAlternateProtocol; | 182 const AlternateProtocolInfo kNoAlternateProtocol; |
| 178 | 183 |
| 179 if (!session_->params().use_alternate_protocols) | 184 if (!session_->params().use_alternate_protocols) |
| 180 return kNoAlternateProtocol; | 185 return kNoAlternateProtocol; |
| 181 | 186 |
| 182 if (original_url.SchemeIs("ftp")) | 187 if (original_url.SchemeIs("ftp")) |
| 183 return kNoAlternateProtocol; | 188 return kNoAlternateProtocol; |
| 184 | 189 |
| 190 if (load_flags & LOAD_UNENCRYPTED_HTTP11) |
| 191 return kNoAlternateProtocol; |
| 192 |
| 185 HostPortPair origin = HostPortPair::FromURL(original_url); | 193 HostPortPair origin = HostPortPair::FromURL(original_url); |
| 186 HttpServerProperties& http_server_properties = | 194 HttpServerProperties& http_server_properties = |
| 187 *session_->http_server_properties(); | 195 *session_->http_server_properties(); |
| 188 const AlternateProtocolInfo alternate = | 196 const AlternateProtocolInfo alternate = |
| 189 http_server_properties.GetAlternateProtocol(origin); | 197 http_server_properties.GetAlternateProtocol(origin); |
| 190 | 198 |
| 191 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 199 if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 192 return kNoAlternateProtocol; | 200 return kNoAlternateProtocol; |
| 193 if (alternate.is_broken) { | 201 if (alternate.is_broken) { |
| 194 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); | 202 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 delete job; | 302 delete job; |
| 295 } | 303 } |
| 296 | 304 |
| 297 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 305 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
| 298 preconnect_job_set_.erase(job); | 306 preconnect_job_set_.erase(job); |
| 299 delete job; | 307 delete job; |
| 300 OnPreconnectsCompleteInternal(); | 308 OnPreconnectsCompleteInternal(); |
| 301 } | 309 } |
| 302 | 310 |
| 303 } // namespace net | 311 } // namespace net |
| OLD | NEW |