Chromium Code Reviews| Index: net/http/http_stream_factory_impl_request.cc |
| diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_factory_impl_request.cc |
| index 9e2f9dc3d94c49a617ee2cd23066175424a470a1..2b44fb0454f55de5c03d13c3e64030e214292d33 100644 |
| --- a/net/http/http_stream_factory_impl_request.cc |
| +++ b/net/http/http_stream_factory_impl_request.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/callback.h" |
| #include "base/logging.h" |
| #include "base/stl_util.h" |
| +#include "net/http/bidirectional_stream.h" |
| #include "net/http/http_stream_factory_impl_job.h" |
| #include "net/spdy/spdy_http_stream.h" |
| #include "net/spdy/spdy_session.h" |
| @@ -20,6 +21,21 @@ HttpStreamFactoryImpl::Request::Request( |
| WebSocketHandshakeStreamBase::CreateHelper* |
| websocket_handshake_stream_create_helper, |
| const BoundNetLog& net_log) |
| + : Request(url, |
| + factory, |
| + delegate, |
| + websocket_handshake_stream_create_helper, |
| + net_log, |
| + false) {} |
| + |
| +HttpStreamFactoryImpl::Request::Request( |
|
mef
2015/09/30 16:18:16
why do we need to duplicate constructors? Can we a
xunjieli
2015/10/01 18:41:16
Done.
|
| + const GURL& url, |
| + HttpStreamFactoryImpl* factory, |
| + HttpStreamRequest::Delegate* delegate, |
| + WebSocketHandshakeStreamBase::CreateHelper* |
| + websocket_handshake_stream_create_helper, |
| + const BoundNetLog& net_log, |
| + bool for_bidirectional) |
| : url_(url), |
| factory_(factory), |
| websocket_handshake_stream_create_helper_( |
| @@ -29,7 +45,8 @@ HttpStreamFactoryImpl::Request::Request( |
| completed_(false), |
| was_npn_negotiated_(false), |
| protocol_negotiated_(kProtoUnknown), |
| - using_spdy_(false) { |
| + using_spdy_(false), |
| + for_bidirectional_(for_bidirectional) { |
| DCHECK(factory_); |
| DCHECK(delegate_); |
| @@ -77,6 +94,7 @@ void HttpStreamFactoryImpl::Request::OnStreamReady( |
| const ProxyInfo& used_proxy_info, |
| HttpStream* stream) { |
| DCHECK(!factory_->for_websockets_); |
| + DCHECK(!for_bidirectional_); |
| DCHECK(stream); |
| DCHECK(completed_); |
| @@ -84,12 +102,28 @@ void HttpStreamFactoryImpl::Request::OnStreamReady( |
| delegate_->OnStreamReady(used_ssl_config, used_proxy_info, stream); |
| } |
| +void HttpStreamFactoryImpl::Request::OnBidirectionalStreamReady( |
| + Job* job, |
| + const SSLConfig& used_ssl_config, |
| + const ProxyInfo& used_proxy_info, |
| + BidirectionalStream* stream) { |
| + DCHECK(!factory_->for_websockets_); |
| + DCHECK(for_bidirectional_); |
| + DCHECK(stream); |
| + DCHECK(completed_); |
| + |
| + OnJobSucceeded(job); |
| + delegate_->OnBidirectionalStreamReady(used_ssl_config, used_proxy_info, |
| + stream); |
| +} |
| + |
| void HttpStreamFactoryImpl::Request::OnWebSocketHandshakeStreamReady( |
| Job* job, |
| const SSLConfig& used_ssl_config, |
| const ProxyInfo& used_proxy_info, |
| WebSocketHandshakeStreamBase* stream) { |
| DCHECK(factory_->for_websockets_); |
| + DCHECK(!for_bidirectional_); |
| DCHECK(stream); |
| DCHECK(completed_); |
| @@ -252,6 +286,7 @@ bool HttpStreamFactoryImpl::Request::HasSpdySessionKey() const { |
| void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
| Job* job, |
| scoped_ptr<HttpStream> stream, |
| + scoped_ptr<BidirectionalStream> bidirectional_stream, |
| const base::WeakPtr<SpdySession>& spdy_session, |
| bool direct) { |
| DCHECK(job); |
| @@ -286,6 +321,10 @@ void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
| // TODO(ricea): Re-instate this code when WebSockets over SPDY is |
| // implemented. |
| NOTREACHED(); |
| + } else if (for_bidirectional_) { |
|
mef
2015/09/30 16:18:16
Does this only work for new spdy session?
xunjieli
2015/10/01 18:41:16
It also works for existing spdy session if HttpStr
|
| + delegate_->OnBidirectionalStreamReady(job->server_ssl_config(), |
| + job->proxy_info(), |
| + bidirectional_stream.release()); |
| } else { |
| delegate_->OnStreamReady(job->server_ssl_config(), job->proxy_info(), |
| stream.release()); |