| Index: net/quic/quic_stream_factory.cc
|
| diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
|
| index 039915bf735bc6a3a15bd77e0d0be64dae7e7d47..3cbe9cf3d118123dbbfef4f0947240197e1bc779 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;
|
|
|
| @@ -512,11 +517,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) {
|
| @@ -527,13 +532,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) {
|
| @@ -548,11 +553,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,
|
| @@ -778,7 +793,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;
|
| }
|
| @@ -796,7 +811,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;
|
| }
|
| }
|
| @@ -852,7 +867,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;
|
| }
|
| @@ -930,7 +945,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;
|
| }
|
| }
|
|
|