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 b2a9ef02a0bece72f802f63e86f7cb85b93f17fe..e39a03e862227a8f86761f08c1d22fbade9d70aa 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_job.h" |
| #include "net/http/http_stream_factory_impl_job.h" |
| #include "net/spdy/spdy_http_stream.h" |
| #include "net/spdy/spdy_session.h" |
| @@ -19,7 +20,8 @@ HttpStreamFactoryImpl::Request::Request( |
| HttpStreamRequest::Delegate* delegate, |
| WebSocketHandshakeStreamBase::CreateHelper* |
| websocket_handshake_stream_create_helper, |
| - const BoundNetLog& net_log) |
| + const BoundNetLog& net_log, |
| + StreamType stream_type) |
| : url_(url), |
| factory_(factory), |
| websocket_handshake_stream_create_helper_( |
| @@ -29,7 +31,8 @@ HttpStreamFactoryImpl::Request::Request( |
| completed_(false), |
| was_npn_negotiated_(false), |
| protocol_negotiated_(kProtoUnknown), |
| - using_spdy_(false) { |
| + using_spdy_(false), |
| + for_bidirectional_(stream_type == BIDIRECTIONAL_STREAM_SPDY_JOB) { |
| DCHECK(factory_); |
| DCHECK(delegate_); |
| @@ -77,6 +80,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 +88,28 @@ void HttpStreamFactoryImpl::Request::OnStreamReady( |
| delegate_->OnStreamReady(used_ssl_config, used_proxy_info, stream); |
| } |
| +void HttpStreamFactoryImpl::Request::OnBidirectionalStreamJobReady( |
| + Job* job, |
| + const SSLConfig& used_ssl_config, |
| + const ProxyInfo& used_proxy_info, |
| + BidirectionalStreamJob* stream) { |
|
mef
2015/12/21 23:21:31
stream -> stream_job?
xunjieli
2015/12/22 02:58:49
Done.
|
| + DCHECK(!factory_->for_websockets_); |
| + DCHECK(for_bidirectional_); |
| + DCHECK(stream); |
| + DCHECK(completed_); |
| + |
| + OnJobSucceeded(job); |
| + delegate_->OnBidirectionalStreamJobReady(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 +272,7 @@ bool HttpStreamFactoryImpl::Request::HasSpdySessionKey() const { |
| void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
| Job* job, |
| scoped_ptr<HttpStream> stream, |
| + scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job, |
| const base::WeakPtr<SpdySession>& spdy_session, |
| bool direct) { |
| DCHECK(job); |
| @@ -286,7 +307,15 @@ void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
| // TODO(ricea): Re-instate this code when WebSockets over SPDY is |
| // implemented. |
| NOTREACHED(); |
| + } else if (for_bidirectional_) { |
| + DCHECK(bidirectional_stream_job); |
| + DCHECK(!stream); |
| + delegate_->OnBidirectionalStreamJobReady( |
| + job->server_ssl_config(), job->proxy_info(), |
| + bidirectional_stream_job.release()); |
| } else { |
| + DCHECK(!bidirectional_stream_job); |
| + DCHECK(stream); |
| delegate_->OnStreamReady(job->server_ssl_config(), job->proxy_info(), |
| stream.release()); |
| } |