Index: net/http/http_stream_factory_impl_job.cc |
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc |
index 8955017cded8a4ef938881953c037601cad7bffe..f6f05b97fd7ff41841391fa6227bc67858b29a10 100644 |
--- a/net/http/http_stream_factory_impl_job.cc |
+++ b/net/http/http_stream_factory_impl_job.cc |
@@ -41,6 +41,7 @@ |
#include "net/socket/socks_client_socket_pool.h" |
#include "net/socket/ssl_client_socket.h" |
#include "net/socket/ssl_client_socket_pool.h" |
+#include "net/spdy/bidirectional_spdy_stream.h" |
#include "net/spdy/spdy_http_stream.h" |
#include "net/spdy/spdy_session.h" |
#include "net/spdy/spdy_session_pool.h" |
@@ -134,6 +135,7 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |
spdy_session_direct_(false), |
job_status_(STATUS_RUNNING), |
other_job_status_(STATUS_RUNNING), |
+ for_bidirectional_(false), |
ptr_factory_(this) { |
DCHECK(stream_factory); |
DCHECK(session); |
@@ -165,6 +167,8 @@ HttpStreamFactoryImpl::Job::~Job() { |
void HttpStreamFactoryImpl::Job::Start(Request* request) { |
DCHECK(request); |
request_ = request; |
+ // Saves |for_bidirectional_|, since request is nulled when job is orphaned. |
+ for_bidirectional_ = request_->for_bidirectional(); |
StartInternal(); |
} |
@@ -355,8 +359,26 @@ void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { |
// |this| may be deleted after this call. |
} |
+void HttpStreamFactoryImpl::Job::OnBidirectionalStreamReadyCallback() { |
+ DCHECK(bidirectional_stream_); |
+ DCHECK(!IsPreconnecting()); |
+ DCHECK(!stream_factory_->for_websockets_); |
mmenke
2015/10/08 19:31:53
Think the latter two of these make more sense as D
xunjieli
2015/10/19 21:07:46
Hmm.. A few unit tests fail those two DCHECKs if I
|
+ |
+ MaybeCopyConnectionAttemptsFromSocketOrHandle(); |
+ |
+ if (IsOrphaned()) { |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ } else { |
+ request_->Complete(was_npn_negotiated(), protocol_negotiated(), |
+ using_spdy()); |
+ request_->OnBidirectionalStreamReady(this, server_ssl_config_, proxy_info_, |
+ bidirectional_stream_.release()); |
+ } |
+ // |this| may be deleted after this call. |
+} |
+ |
void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { |
- DCHECK(stream_.get()); |
+ DCHECK(stream_.get() || bidirectional_stream_.get()); |
DCHECK(!IsPreconnecting()); |
DCHECK(using_spdy()); |
// Note: an event loop iteration has passed, so |new_spdy_session_| may be |
@@ -376,8 +398,16 @@ void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { |
} |
stream_factory_->OnOrphanedJobComplete(this); |
} else { |
- request_->OnNewSpdySessionReady( |
- this, stream_.Pass(), spdy_session, spdy_session_direct_); |
+ if (for_bidirectional_) { |
+ request_->OnNewSpdySessionReady(this, /*spdy_http_stream=*/nullptr, |
+ bidirectional_stream_.Pass(), |
+ spdy_session, spdy_session_direct_); |
+ |
+ } else { |
+ request_->OnNewSpdySessionReady(this, stream_.Pass(), |
+ /** bidirectional_stream=*/nullptr, |
+ spdy_session, spdy_session_direct_); |
+ } |
} |
// |this| may be deleted after this call. |
} |
@@ -564,6 +594,16 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
FROM_HERE, base::Bind(&Job::OnWebSocketHandshakeStreamReadyCallback, |
ptr_factory_.GetWeakPtr())); |
+ } else if (for_bidirectional_) { |
mmenke
2015/10/08 19:31:53
Hrm...Should we fail earlier for non-HTTPS/HTTP2 r
xunjieli
2015/10/19 21:07:46
I added a check in the wrapper to fail early for n
|
+ if (bidirectional_stream_ == nullptr) { |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, base::Bind(&Job::OnStreamFailedCallback, |
+ ptr_factory_.GetWeakPtr(), ERR_FAILED)); |
+ } else { |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, base::Bind(&Job::OnBidirectionalStreamReadyCallback, |
+ ptr_factory_.GetWeakPtr())); |
+ } |
} else { |
DCHECK(stream_.get()); |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
@@ -1148,6 +1188,11 @@ int HttpStreamFactoryImpl::Job::SetSpdyHttpStream( |
// implemented. |
if (stream_factory_->for_websockets_) |
return ERR_NOT_IMPLEMENTED; |
+ if (for_bidirectional_) { |
+ // TODO(xunjieli): Enable creation of QUIC's version of BidirectionalStream. |
+ bidirectional_stream_.reset(new BidirectionalSpdyStream(session)); |
+ return OK; |
+ } |
// TODO(willchan): Delete this code, because eventually, the |
// HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it |