Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: net/http/http_stream_factory_impl.cc

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) {
86 DCHECK(!for_websockets_);
87 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme));
88
89 // TODO(xunjieli): Enable creation of QUIC's version of
90 // BidirectionalStream.
91
92 Request* request = new Request(request_info.url, this, delegate, nullptr,
93 net_log, true /** for_bidirectional */);
mef 2015/10/20 21:56:35 Can we define some enum for stream type like 'STRE
xunjieli 2015/10/21 19:35:36 Done. Good idea!
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, false /** for_bidirectional */);
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // queue (Order by priority first, then FIFO within same priority). Unclear 275 // queue (Order by priority first, then FIFO within same priority). Unclear
254 // that it matters here. 276 // that it matters here.
255 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) 277 if (!ContainsKey(spdy_session_request_map_, spdy_session_key))
256 break; 278 break;
257 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); 279 Request* request = *spdy_session_request_map_[spdy_session_key].begin();
258 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); 280 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy);
259 if (for_websockets_) { 281 if (for_websockets_) {
260 // TODO(ricea): Restore this code path when WebSocket over SPDY 282 // TODO(ricea): Restore this code path when WebSocket over SPDY
261 // implementation is ready. 283 // implementation is ready.
262 NOTREACHED(); 284 NOTREACHED();
285 } else if (request->for_bidirectional()) {
286 request->OnBidirectionalStreamReady(
287 nullptr, used_ssl_config, used_proxy_info,
288 new BidirectionalSpdyStream(spdy_session));
263 } else { 289 } else {
264 bool use_relative_url = direct || request->url().SchemeIs("https"); 290 bool use_relative_url = direct || request->url().SchemeIs("https");
265 request->OnStreamReady( 291 request->OnStreamReady(
266 NULL, 292 nullptr, used_ssl_config, used_proxy_info,
267 used_ssl_config,
268 used_proxy_info,
269 new SpdyHttpStream(spdy_session, use_relative_url)); 293 new SpdyHttpStream(spdy_session, use_relative_url));
270 } 294 }
271 } 295 }
272 // TODO(mbelshe): Alert other valid requests. 296 // TODO(mbelshe): Alert other valid requests.
273 } 297 }
274 298
275 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { 299 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) {
276 orphaned_job_set_.erase(job); 300 orphaned_job_set_.erase(job);
277 delete job; 301 delete job;
278 } 302 }
279 303
280 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 304 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
281 preconnect_job_set_.erase(job); 305 preconnect_job_set_.erase(job);
282 delete job; 306 delete job;
283 OnPreconnectsCompleteInternal(); 307 OnPreconnectsCompleteInternal();
284 } 308 }
285 309
286 } // namespace net 310 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698