| 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> |
| 8 |
| 7 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 9 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" |
| 11 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 12 #include "net/http/http_network_session.h" | 14 #include "net/http/http_network_session.h" |
| 13 #include "net/http/http_pipelined_connection.h" | 15 #include "net/http/http_pipelined_connection.h" |
| 14 #include "net/http/http_pipelined_host.h" | 16 #include "net/http/http_pipelined_host.h" |
| 15 #include "net/http/http_pipelined_stream.h" | 17 #include "net/http/http_pipelined_stream.h" |
| 16 #include "net/http/http_server_properties.h" | 18 #include "net/http/http_server_properties.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 DCHECK(preconnect_job_set_.empty()); | 63 DCHECK(preconnect_job_set_.empty()); |
| 62 } | 64 } |
| 63 | 65 |
| 64 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 66 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 65 const HttpRequestInfo& request_info, | 67 const HttpRequestInfo& request_info, |
| 66 RequestPriority priority, | 68 RequestPriority priority, |
| 67 const SSLConfig& server_ssl_config, | 69 const SSLConfig& server_ssl_config, |
| 68 const SSLConfig& proxy_ssl_config, | 70 const SSLConfig& proxy_ssl_config, |
| 69 HttpStreamRequest::Delegate* delegate, | 71 HttpStreamRequest::Delegate* delegate, |
| 70 const BoundNetLog& net_log) { | 72 const BoundNetLog& net_log) { |
| 71 Request* request = new Request(request_info.url, this, delegate, net_log); | 73 return RequestStreamInternal(request_info, |
| 74 priority, |
| 75 server_ssl_config, |
| 76 proxy_ssl_config, |
| 77 delegate, |
| 78 net_log, |
| 79 false); |
| 80 } |
| 81 |
| 82 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamForWebSocket( |
| 83 const HttpRequestInfo& request_info, |
| 84 RequestPriority priority, |
| 85 const SSLConfig& server_ssl_config, |
| 86 const SSLConfig& proxy_ssl_config, |
| 87 HttpStreamRequest::Delegate* delegate, |
| 88 const BoundNetLog& net_log) { |
| 89 return RequestStreamInternal(request_info, |
| 90 priority, |
| 91 server_ssl_config, |
| 92 proxy_ssl_config, |
| 93 delegate, |
| 94 net_log, |
| 95 true); |
| 96 } |
| 97 |
| 98 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( |
| 99 const HttpRequestInfo& request_info, |
| 100 RequestPriority priority, |
| 101 const SSLConfig& server_ssl_config, |
| 102 const SSLConfig& proxy_ssl_config, |
| 103 HttpStreamRequest::Delegate* delegate, |
| 104 const BoundNetLog& net_log, |
| 105 bool for_websocket) { |
| 106 Request* request = |
| 107 new Request(request_info.url, this, delegate, net_log, for_websocket); |
| 72 | 108 |
| 73 GURL alternate_url; | 109 GURL alternate_url; |
| 74 PortAlternateProtocolPair alternate = | 110 PortAlternateProtocolPair alternate = |
| 75 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); | 111 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); |
| 76 Job* alternate_job = NULL; | 112 Job* alternate_job = NULL; |
| 77 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 113 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 78 // Never share connection with other jobs for FTP requests. | 114 // Never share connection with other jobs for FTP requests. |
| 79 DCHECK(!request_info.url.SchemeIs("ftp")); | 115 DCHECK(!request_info.url.SchemeIs("ftp")); |
| 80 | 116 |
| 81 HttpRequestInfo alternate_request_info = request_info; | 117 HttpRequestInfo alternate_request_info = request_info; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } else { | 227 } else { |
| 192 DCHECK_EQ(QUIC, alternate.protocol); | 228 DCHECK_EQ(QUIC, alternate.protocol); |
| 193 if (!session_->params().enable_quic || | 229 if (!session_->params().enable_quic || |
| 194 !original_url.SchemeIs("http")) | 230 !original_url.SchemeIs("http")) |
| 195 return kNoAlternateProtocol; | 231 return kNoAlternateProtocol; |
| 196 // TODO(rch): Figure out how to make QUIC iteract with PAC | 232 // TODO(rch): Figure out how to make QUIC iteract with PAC |
| 197 // scripts. By not re-writing the URL, we will query the PAC script | 233 // scripts. By not re-writing the URL, we will query the PAC script |
| 198 // for the proxy to use to reach the original URL via TCP. But | 234 // for the proxy to use to reach the original URL via TCP. But |
| 199 // the alternate request will be going via UDP to a different port. | 235 // the alternate request will be going via UDP to a different port. |
| 200 *alternate_url = original_url; | 236 *alternate_url = original_url; |
| 201 } | 237 } |
| 202 return alternate; | 238 return alternate; |
| 203 } | 239 } |
| 204 | 240 |
| 205 void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) { | 241 void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) { |
| 206 DCHECK(ContainsKey(request_map_, job)); | 242 DCHECK(ContainsKey(request_map_, job)); |
| 207 DCHECK_EQ(request_map_[job], request); | 243 DCHECK_EQ(request_map_[job], request); |
| 208 DCHECK(!ContainsKey(orphaned_job_set_, job)); | 244 DCHECK(!ContainsKey(orphaned_job_set_, job)); |
| 209 | 245 |
| 210 request_map_.erase(job); | 246 request_map_.erase(job); |
| 211 | 247 |
| 212 orphaned_job_set_.insert(job); | 248 orphaned_job_set_.insert(job); |
| 213 job->Orphan(request); | 249 job->Orphan(request); |
| 214 } | 250 } |
| 215 | 251 |
| 216 void HttpStreamFactoryImpl::OnSpdySessionReady( | 252 void HttpStreamFactoryImpl::OnNewSpdySessionReady( |
| 217 scoped_refptr<SpdySession> spdy_session, | 253 scoped_refptr<SpdySession> spdy_session, |
| 218 bool direct, | 254 bool direct, |
| 219 const SSLConfig& used_ssl_config, | 255 const SSLConfig& used_ssl_config, |
| 220 const ProxyInfo& used_proxy_info, | 256 const ProxyInfo& used_proxy_info, |
| 221 bool was_npn_negotiated, | 257 bool was_npn_negotiated, |
| 222 NextProto protocol_negotiated, | 258 NextProto protocol_negotiated, |
| 223 bool using_spdy, | 259 bool using_spdy, |
| 224 const BoundNetLog& net_log) { | 260 const BoundNetLog& net_log) { |
| 225 const HostPortProxyPair& spdy_session_key = | 261 const HostPortProxyPair& spdy_session_key = |
| 226 spdy_session->host_port_proxy_pair(); | 262 spdy_session->host_port_proxy_pair(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 it != requests_to_fail.end(); ++it) { | 323 it != requests_to_fail.end(); ++it) { |
| 288 Request* request = *it; | 324 Request* request = *it; |
| 289 if (request == request_map_[job]) { | 325 if (request == request_map_[job]) { |
| 290 continue; | 326 continue; |
| 291 } | 327 } |
| 292 request->OnStreamFailed(NULL, status, used_ssl_config); | 328 request->OnStreamFailed(NULL, status, used_ssl_config); |
| 293 } | 329 } |
| 294 } | 330 } |
| 295 | 331 |
| 296 } // namespace net | 332 } // namespace net |
| OLD | NEW |