| Index: net/quic/quic_stream_factory.cc
|
| diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
|
| index 9f633d5aa8f12b4d4ea34a1ef339f8b598a6ed21..03fb2cc213e8d2904166cd9a5e9b465c21ad5c01 100644
|
| --- a/net/quic/quic_stream_factory.cc
|
| +++ b/net/quic/quic_stream_factory.cc
|
| @@ -61,6 +61,11 @@
|
| #include "base/cpu.h"
|
| #endif
|
|
|
| +#if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
|
| +#include "net/http/bidirectional_stream_job.h"
|
| +#include "net/quic/bidirectional_stream_quic_impl.h"
|
| +#endif
|
| +
|
| using std::min;
|
| using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle;
|
|
|
| @@ -513,11 +518,11 @@ int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
|
| base::StringPiece method,
|
| const BoundNetLog& net_log,
|
| const CompletionCallback& callback) {
|
| - DCHECK(!stream_);
|
| DCHECK(callback_.is_null());
|
| DCHECK(factory_);
|
| origin_host_ = url.host();
|
| privacy_mode_ = privacy_mode;
|
| +
|
| int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags,
|
| url, method, net_log, this);
|
| if (rv == ERR_IO_PENDING) {
|
| @@ -528,13 +533,13 @@ int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
|
| factory_ = nullptr;
|
| }
|
| if (rv == OK)
|
| - DCHECK(stream_);
|
| + DCHECK(session_);
|
| return rv;
|
| }
|
|
|
| -void QuicStreamRequest::set_stream(scoped_ptr<QuicHttpStream> stream) {
|
| - DCHECK(stream);
|
| - stream_ = std::move(stream);
|
| +void QuicStreamRequest::SetSession(QuicChromiumClientSession* session) {
|
| + DCHECK(session);
|
| + session_ = session->GetWeakPtr();
|
| }
|
|
|
| void QuicStreamRequest::OnRequestComplete(int rv) {
|
| @@ -549,11 +554,21 @@ base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const {
|
| QuicServerId(host_port_pair_, privacy_mode_));
|
| }
|
|
|
| -scoped_ptr<QuicHttpStream> QuicStreamRequest::ReleaseStream() {
|
| - DCHECK(stream_);
|
| - return std::move(stream_);
|
| +scoped_ptr<QuicHttpStream> QuicStreamRequest::CreateStream() {
|
| + if (!session_)
|
| + return nullptr;
|
| + return make_scoped_ptr(new QuicHttpStream(session_));
|
| }
|
|
|
| +#if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
|
| +scoped_ptr<BidirectionalStreamJob>
|
| +QuicStreamRequest::CreateBidirectionalStreamJob() {
|
| + if (!session_)
|
| + return nullptr;
|
| + return make_scoped_ptr(new BidirectionalStreamQuicImpl(session_));
|
| +}
|
| +#endif
|
| +
|
| QuicStreamFactory::QuicStreamFactory(
|
| HostResolver* host_resolver,
|
| ClientSocketFactory* client_socket_factory,
|
| @@ -780,7 +795,7 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
|
| static_cast<QuicChromiumClientSession*>(promised->session());
|
| DCHECK(session);
|
| if (session->server_id().privacy_mode() == privacy_mode) {
|
| - request->set_stream(CreateFromSession(session));
|
| + request->SetSession(session);
|
| ++num_push_streams_created_;
|
| return OK;
|
| }
|
| @@ -798,7 +813,7 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
|
| QuicChromiumClientSession* session = it->second;
|
| if (!session->CanPool(url.host(), privacy_mode))
|
| return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
|
| - request->set_stream(CreateFromSession(session));
|
| + request->SetSession(session);
|
| return OK;
|
| }
|
| }
|
| @@ -854,7 +869,7 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
|
| QuicChromiumClientSession* session = it->second;
|
| if (!session->CanPool(url.host(), privacy_mode))
|
| return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
|
| - request->set_stream(CreateFromSession(session));
|
| + request->SetSession(session);
|
| }
|
| return rv;
|
| }
|
| @@ -932,7 +947,7 @@ void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
|
| request->OnRequestComplete(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN);
|
| continue;
|
| }
|
| - request->set_stream(CreateFromSession(session));
|
| + request->SetSession(session);
|
| ++request_it;
|
| }
|
| }
|
|
|