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

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: 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/bidirectional_stream.h"
12 #include "net/http/http_network_session.h" 13 #include "net/http/http_network_session.h"
13 #include "net/http/http_server_properties.h" 14 #include "net/http/http_server_properties.h"
14 #include "net/http/http_stream_factory_impl_job.h" 15 #include "net/http/http_stream_factory_impl_job.h"
15 #include "net/http/http_stream_factory_impl_request.h" 16 #include "net/http/http_stream_factory_impl_request.h"
16 #include "net/log/net_log.h" 17 #include "net/log/net_log.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
(...skipping 46 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 Request* request =
88 new Request(request_info.url, this, delegate, nullptr, net_log, true);
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,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // queue (Order by priority first, then FIFO within same priority). Unclear 272 // queue (Order by priority first, then FIFO within same priority). Unclear
254 // that it matters here. 273 // that it matters here.
255 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) 274 if (!ContainsKey(spdy_session_request_map_, spdy_session_key))
256 break; 275 break;
257 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); 276 Request* request = *spdy_session_request_map_[spdy_session_key].begin();
258 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); 277 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy);
259 if (for_websockets_) { 278 if (for_websockets_) {
260 // TODO(ricea): Restore this code path when WebSocket over SPDY 279 // TODO(ricea): Restore this code path when WebSocket over SPDY
261 // implementation is ready. 280 // implementation is ready.
262 NOTREACHED(); 281 NOTREACHED();
282 } else if (request->for_bidirectional()) {
283 request->OnBidirectionalStreamReady(
284 nullptr, used_ssl_config, used_proxy_info,
285 new BidirectionalStream(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698