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