| 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 "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
| 12 #include "net/http/http_network_session.h" | 12 #include "net/http/http_network_session.h" |
| 13 #include "net/http/http_server_properties.h" | 13 #include "net/http/http_server_properties.h" |
| 14 #include "net/http/http_stream_factory_impl_job.h" | 14 #include "net/http/http_stream_factory_impl_job.h" |
| 15 #include "net/http/http_stream_factory_impl_request.h" | 15 #include "net/http/http_stream_factory_impl_request.h" |
| 16 #include "net/log/net_log.h" | 16 #include "net/log/net_log.h" |
| 17 #include "net/quic/quic_server_id.h" | 17 #include "net/quic/quic_server_id.h" |
| 18 #include "net/spdy/bidirectional_stream_spdy_job.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 { |
| 22 | 23 |
| 23 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 24 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
| 24 bool for_websockets) | 25 bool for_websockets) |
| 25 : session_(session), | 26 : session_(session), |
| 26 for_websockets_(for_websockets) {} | 27 for_websockets_(for_websockets) {} |
| 27 | 28 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 DCHECK(create_helper); | 70 DCHECK(create_helper); |
| 70 return RequestStreamInternal(request_info, | 71 return RequestStreamInternal(request_info, |
| 71 priority, | 72 priority, |
| 72 server_ssl_config, | 73 server_ssl_config, |
| 73 proxy_ssl_config, | 74 proxy_ssl_config, |
| 74 delegate, | 75 delegate, |
| 75 create_helper, | 76 create_helper, |
| 76 net_log); | 77 net_log); |
| 77 } | 78 } |
| 78 | 79 |
| 80 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamJob( |
| 81 const HttpRequestInfo& request_info, |
| 82 RequestPriority priority, |
| 83 const SSLConfig& server_ssl_config, |
| 84 const SSLConfig& proxy_ssl_config, |
| 85 HttpStreamRequest::Delegate* delegate, |
| 86 const BoundNetLog& net_log) { |
| 87 DCHECK(!for_websockets_); |
| 88 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); |
| 89 |
| 90 // TODO(xunjieli): Create QUIC's version of BidirectionalStreamJob. |
| 91 |
| 92 Request* request = |
| 93 new Request(request_info.url, this, delegate, nullptr, net_log, |
| 94 Request::BIDIRECTIONAL_STREAM_SPDY_JOB); |
| 95 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 96 proxy_ssl_config, net_log.net_log()); |
| 97 request->AttachJob(job); |
| 98 |
| 99 job->Start(request); |
| 100 return request; |
| 101 } |
| 102 |
| 79 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( | 103 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( |
| 80 const HttpRequestInfo& request_info, | 104 const HttpRequestInfo& request_info, |
| 81 RequestPriority priority, | 105 RequestPriority priority, |
| 82 const SSLConfig& server_ssl_config, | 106 const SSLConfig& server_ssl_config, |
| 83 const SSLConfig& proxy_ssl_config, | 107 const SSLConfig& proxy_ssl_config, |
| 84 HttpStreamRequest::Delegate* delegate, | 108 HttpStreamRequest::Delegate* delegate, |
| 85 WebSocketHandshakeStreamBase::CreateHelper* | 109 WebSocketHandshakeStreamBase::CreateHelper* |
| 86 websocket_handshake_stream_create_helper, | 110 websocket_handshake_stream_create_helper, |
| 87 const BoundNetLog& net_log) { | 111 const BoundNetLog& net_log) { |
| 88 Request* request = new Request(request_info.url, | 112 Request* request = new Request(request_info.url, this, delegate, |
| 89 this, | |
| 90 delegate, | |
| 91 websocket_handshake_stream_create_helper, | 113 websocket_handshake_stream_create_helper, |
| 92 net_log); | 114 net_log, Request::HTTP_STREAM); |
| 93 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 115 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 94 proxy_ssl_config, net_log.net_log()); | 116 proxy_ssl_config, net_log.net_log()); |
| 95 request->AttachJob(job); | 117 request->AttachJob(job); |
| 96 | 118 |
| 97 const AlternativeServiceVector alternative_service_vector = | 119 const AlternativeServiceVector alternative_service_vector = |
| 98 GetAlternativeServicesFor(request_info.url, delegate); | 120 GetAlternativeServicesFor(request_info.url, delegate); |
| 99 | 121 |
| 100 if (!alternative_service_vector.empty()) { | 122 if (!alternative_service_vector.empty()) { |
| 101 // TODO(bnc): Pass on multiple alternative services to Job. | 123 // TODO(bnc): Pass on multiple alternative services to Job. |
| 102 const AlternativeService& alternative_service = | 124 const AlternativeService& alternative_service = |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // queue (Order by priority first, then FIFO within same priority). Unclear | 290 // queue (Order by priority first, then FIFO within same priority). Unclear |
| 269 // that it matters here. | 291 // that it matters here. |
| 270 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) | 292 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) |
| 271 break; | 293 break; |
| 272 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 294 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); |
| 273 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); | 295 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); |
| 274 if (for_websockets_) { | 296 if (for_websockets_) { |
| 275 // TODO(ricea): Restore this code path when WebSocket over SPDY | 297 // TODO(ricea): Restore this code path when WebSocket over SPDY |
| 276 // implementation is ready. | 298 // implementation is ready. |
| 277 NOTREACHED(); | 299 NOTREACHED(); |
| 300 } else if (request->for_bidirectional()) { |
| 301 request->OnBidirectionalStreamJobReady( |
| 302 nullptr, used_ssl_config, used_proxy_info, |
| 303 new BidirectionalStreamSpdyJob(spdy_session)); |
| 278 } else { | 304 } else { |
| 279 bool use_relative_url = direct || request->url().SchemeIs("https"); | 305 bool use_relative_url = direct || request->url().SchemeIs("https"); |
| 280 request->OnStreamReady( | 306 request->OnStreamReady( |
| 281 NULL, | 307 nullptr, used_ssl_config, used_proxy_info, |
| 282 used_ssl_config, | |
| 283 used_proxy_info, | |
| 284 new SpdyHttpStream(spdy_session, use_relative_url)); | 308 new SpdyHttpStream(spdy_session, use_relative_url)); |
| 285 } | 309 } |
| 286 } | 310 } |
| 287 // TODO(mbelshe): Alert other valid requests. | 311 // TODO(mbelshe): Alert other valid requests. |
| 288 } | 312 } |
| 289 | 313 |
| 290 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { | 314 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { |
| 291 orphaned_job_set_.erase(job); | 315 orphaned_job_set_.erase(job); |
| 292 delete job; | 316 delete job; |
| 293 } | 317 } |
| 294 | 318 |
| 295 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 319 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
| 296 preconnect_job_set_.erase(job); | 320 preconnect_job_set_.erase(job); |
| 297 delete job; | 321 delete job; |
| 298 OnPreconnectsCompleteInternal(); | 322 OnPreconnectsCompleteInternal(); |
| 299 } | 323 } |
| 300 | 324 |
| 301 } // namespace net | 325 } // namespace net |
| OLD | NEW |