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_spdy_stream.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::RequestBidirectionalStream( | |
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) { | |
mmenke
2015/10/08 19:31:53
DCHECK the scheme is HTTPS?
xunjieli
2015/10/19 21:07:46
Done.
| |
86 DCHECK(!for_websockets_); | |
87 Request* request = new Request(request_info.url, this, delegate, nullptr, | |
88 net_log, true /** for_bidirectional */); | |
mmenke
2015/10/08 19:31:53
I'm no HTTP2 expert, but it's my understanding tha
xunjieli
2015/10/19 21:07:46
Acknowledged. Here we don't use RequestStreamInter
| |
89 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | |
90 proxy_ssl_config, net_log.net_log()); | |
91 request->AttachJob(job); | |
92 | |
93 job->Start(request); | |
94 return request; | |
95 } | |
96 | |
78 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( | 97 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( |
79 const HttpRequestInfo& request_info, | 98 const HttpRequestInfo& request_info, |
80 RequestPriority priority, | 99 RequestPriority priority, |
81 const SSLConfig& server_ssl_config, | 100 const SSLConfig& server_ssl_config, |
82 const SSLConfig& proxy_ssl_config, | 101 const SSLConfig& proxy_ssl_config, |
83 HttpStreamRequest::Delegate* delegate, | 102 HttpStreamRequest::Delegate* delegate, |
84 WebSocketHandshakeStreamBase::CreateHelper* | 103 WebSocketHandshakeStreamBase::CreateHelper* |
85 websocket_handshake_stream_create_helper, | 104 websocket_handshake_stream_create_helper, |
86 const BoundNetLog& net_log) { | 105 const BoundNetLog& net_log) { |
87 Request* request = new Request(request_info.url, | 106 Request* request = new Request(request_info.url, this, delegate, |
88 this, | |
89 delegate, | |
90 websocket_handshake_stream_create_helper, | 107 websocket_handshake_stream_create_helper, |
91 net_log); | 108 net_log, false /** for_bidirectional */); |
92 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 109 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
93 proxy_ssl_config, net_log.net_log()); | 110 proxy_ssl_config, net_log.net_log()); |
94 request->AttachJob(job); | 111 request->AttachJob(job); |
95 | 112 |
96 const AlternativeServiceVector alternative_service_vector = | 113 const AlternativeServiceVector alternative_service_vector = |
97 GetAlternativeServicesFor(request_info.url); | 114 GetAlternativeServicesFor(request_info.url); |
98 if (!alternative_service_vector.empty()) { | 115 if (!alternative_service_vector.empty()) { |
99 // TODO(bnc): Pass on multiple alternative services to Job. | 116 // TODO(bnc): Pass on multiple alternative services to Job. |
100 const AlternativeService& alternative_service = | 117 const AlternativeService& alternative_service = |
101 alternative_service_vector[0]; | 118 alternative_service_vector[0]; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 // queue (Order by priority first, then FIFO within same priority). Unclear | 270 // queue (Order by priority first, then FIFO within same priority). Unclear |
254 // that it matters here. | 271 // that it matters here. |
255 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) | 272 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) |
256 break; | 273 break; |
257 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 274 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); |
258 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); | 275 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); |
259 if (for_websockets_) { | 276 if (for_websockets_) { |
260 // TODO(ricea): Restore this code path when WebSocket over SPDY | 277 // TODO(ricea): Restore this code path when WebSocket over SPDY |
261 // implementation is ready. | 278 // implementation is ready. |
262 NOTREACHED(); | 279 NOTREACHED(); |
280 } else if (request->for_bidirectional()) { | |
281 // TODO(xunjieli): Enable creation of QUIC's version of | |
282 // BidirectionalStream. | |
mmenke
2015/10/08 19:31:53
This seems the wrong place for this comment. Mayb
xunjieli
2015/10/19 21:07:46
Done.
| |
283 request->OnBidirectionalStreamReady( | |
284 nullptr, used_ssl_config, used_proxy_info, | |
285 new BidirectionalSpdyStream(spdy_session)); | |
263 } else { | 286 } else { |
264 bool use_relative_url = direct || request->url().SchemeIs("https"); | 287 bool use_relative_url = direct || request->url().SchemeIs("https"); |
265 request->OnStreamReady( | 288 request->OnStreamReady( |
266 NULL, | 289 nullptr, used_ssl_config, used_proxy_info, |
267 used_ssl_config, | |
268 used_proxy_info, | |
269 new SpdyHttpStream(spdy_session, use_relative_url)); | 290 new SpdyHttpStream(spdy_session, use_relative_url)); |
270 } | 291 } |
271 } | 292 } |
272 // TODO(mbelshe): Alert other valid requests. | 293 // TODO(mbelshe): Alert other valid requests. |
273 } | 294 } |
274 | 295 |
275 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { | 296 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { |
276 orphaned_job_set_.erase(job); | 297 orphaned_job_set_.erase(job); |
277 delete job; | 298 delete job; |
278 } | 299 } |
279 | 300 |
280 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 301 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
281 preconnect_job_set_.erase(job); | 302 preconnect_job_set_.erase(job); |
282 delete job; | 303 delete job; |
283 OnPreconnectsCompleteInternal(); | 304 OnPreconnectsCompleteInternal(); |
284 } | 305 } |
285 | 306 |
286 } // namespace net | 307 } // namespace net |
OLD | NEW |