| Index: net/quic/chromium/quic_http_stream.cc
|
| diff --git a/net/quic/chromium/quic_http_stream.cc b/net/quic/chromium/quic_http_stream.cc
|
| index 5269a7a1fc4d82a5006a9ed06e82d3f4189ff3a8..c606417abe789a23908d9ac4a940bde67cd8c090 100644
|
| --- a/net/quic/chromium/quic_http_stream.cc
|
| +++ b/net/quic/chromium/quic_http_stream.cc
|
| @@ -44,17 +44,12 @@ std::unique_ptr<base::Value> NetLogQuicPushStreamCallback(
|
|
|
| } // namespace
|
|
|
| -QuicHttpStream::QuicHttpStream(
|
| - const base::WeakPtr<QuicChromiumClientSession>& session,
|
| - HttpServerProperties* http_server_properties)
|
| - : MultiplexedHttpStream(MultiplexedSessionHandle(session)),
|
| +QuicHttpStream::QuicHttpStream(QuicChromiumClientSession::Handle session,
|
| + HttpServerProperties* http_server_properties)
|
| + : MultiplexedHttpStream(session),
|
| next_state_(STATE_NONE),
|
| session_(session),
|
| - server_id_(session->server_id()),
|
| http_server_properties_(http_server_properties),
|
| - quic_version_(session->GetQuicVersion()),
|
| - session_error_(ERR_UNEXPECTED),
|
| - was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()),
|
| stream_(nullptr),
|
| request_info_(nullptr),
|
| request_body_stream_(nullptr),
|
| @@ -69,22 +64,17 @@ QuicHttpStream::QuicHttpStream(
|
| closed_stream_sent_bytes_(0),
|
| closed_is_first_stream_(false),
|
| user_buffer_len_(0),
|
| + session_error_(ERR_UNEXPECTED),
|
| quic_connection_error_(QUIC_NO_ERROR),
|
| quic_stream_error_(QUIC_STREAM_NO_ERROR),
|
| - port_migration_detected_(false),
|
| found_promise_(false),
|
| push_handle_(nullptr),
|
| in_loop_(false),
|
| - weak_factory_(this) {
|
| - DCHECK(session_);
|
| - session_->AddObserver(this);
|
| -}
|
| + weak_factory_(this) {}
|
|
|
| QuicHttpStream::~QuicHttpStream() {
|
| CHECK(!in_loop_);
|
| Close(false);
|
| - if (session_)
|
| - session_->RemoveObserver(this);
|
| }
|
|
|
| bool QuicHttpStream::CheckVary(const SpdyHeaderBlock& client_request,
|
| @@ -167,12 +157,12 @@ int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info,
|
| // ERR_QUIC_HANDSHAKE_FAILED. It will retry any request with
|
| // ERR_CONNECTION_CLOSED so long as the connection has been used for other
|
| // streams first and headers have not yet been received.
|
| - if (!session_)
|
| + if (!session_.IsConnected())
|
| return GetResponseStatus();
|
|
|
| stream_net_log.AddEvent(
|
| NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_QUIC_SESSION,
|
| - session_->net_log().source().ToEventParametersCallback());
|
| + session_.net_log().source().ToEventParametersCallback());
|
|
|
| stream_net_log_ = stream_net_log;
|
| request_info_ = request_info;
|
| @@ -183,14 +173,14 @@ int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info,
|
|
|
| std::string url(request_info->url.spec());
|
| QuicClientPromisedInfo* promised =
|
| - session_->push_promise_index()->GetPromised(url);
|
| + session_.GetPushPromiseIndex()->GetPromised(url);
|
| if (promised) {
|
| found_promise_ = true;
|
| stream_net_log_.AddEvent(
|
| NetLogEventType::QUIC_HTTP_STREAM_PUSH_PROMISE_RENDEZVOUS,
|
| base::Bind(&NetLogQuicPushStreamCallback, promised->id(),
|
| &request_info_->url));
|
| - session_->net_log().AddEvent(
|
| + session_.net_log().AddEvent(
|
| NetLogEventType::QUIC_HTTP_STREAM_PUSH_PROMISE_RENDEZVOUS,
|
| base::Bind(&NetLogQuicPushStreamCallback, promised->id(),
|
| &request_info_->url));
|
| @@ -206,7 +196,7 @@ int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info,
|
| }
|
|
|
| int QuicHttpStream::DoHandlePromise() {
|
| - QuicAsyncStatus push_status = session_->push_promise_index()->Try(
|
| + QuicAsyncStatus push_status = session_.GetPushPromiseIndex()->Try(
|
| request_headers_, this, &this->push_handle_);
|
|
|
| switch (push_status) {
|
| @@ -233,7 +223,7 @@ int QuicHttpStream::DoHandlePromiseComplete(int rv) {
|
| NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM,
|
| base::Bind(&NetLogQuicPushStreamCallback, stream_->id(),
|
| &request_info_->url));
|
| - session_->net_log().AddEvent(
|
| + session_.net_log().AddEvent(
|
| NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM,
|
| base::Bind(&NetLogQuicPushStreamCallback, stream_->id(),
|
| &request_info_->url));
|
| @@ -262,7 +252,7 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
|
|
|
| // In order to rendezvous with a push stream, the session still needs to be
|
| // available. Otherwise the stream needs to be available.
|
| - if ((!found_promise_ && !stream_) || !session_)
|
| + if ((!found_promise_ && !stream_) || !session_.IsConnected())
|
| return GetResponseStatus();
|
|
|
| // Store the serialized request headers.
|
| @@ -277,9 +267,9 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
|
| if (found_promise_) {
|
| std::string url(request_info_->url.spec());
|
| QuicClientPromisedInfo* promised =
|
| - session_->push_promise_index()->GetPromised(url);
|
| + session_.GetPushPromiseIndex()->GetPromised(url);
|
| if (promised != nullptr) {
|
| - session_->ResetPromised(promised->id(), QUIC_STREAM_CANCELLED);
|
| + session_.ResetPromised(promised->id(), QUIC_STREAM_CANCELLED);
|
| }
|
| }
|
|
|
| @@ -426,20 +416,17 @@ bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const {
|
| bool QuicHttpStream::GetAlternativeService(
|
| AlternativeService* alternative_service) const {
|
| alternative_service->protocol = kProtoQUIC;
|
| - alternative_service->host = server_id_.host();
|
| - alternative_service->port = server_id_.port();
|
| + alternative_service->host = session_.server_id().host();
|
| + alternative_service->port = session_.server_id().port();
|
| return true;
|
| }
|
|
|
| void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) {
|
| - details->connection_info = ConnectionInfoFromQuicVersion(quic_version_);
|
| - if (was_handshake_confirmed_)
|
| + details->connection_info =
|
| + ConnectionInfoFromQuicVersion(session_.GetQuicVersion());
|
| + session_.PopulateNetErrorDetails(details);
|
| + if (session_.IsCryptoHandshakeConfirmed())
|
| details->quic_connection_error = quic_connection_error_;
|
| - if (session_) {
|
| - session_->PopulateNetErrorDetails(details);
|
| - } else {
|
| - details->quic_port_migration_detected = port_migration_detected_;
|
| - }
|
| }
|
|
|
| void QuicHttpStream::SetPriority(RequestPriority priority) {
|
| @@ -518,24 +505,6 @@ bool QuicHttpStream::HasSendHeadersComplete() {
|
| return next_state_ > STATE_SEND_HEADERS_COMPLETE;
|
| }
|
|
|
| -void QuicHttpStream::OnCryptoHandshakeConfirmed() {
|
| - was_handshake_confirmed_ = true;
|
| -}
|
| -
|
| -void QuicHttpStream::OnSuccessfulVersionNegotiation(
|
| - const QuicVersion& version) {
|
| - quic_version_ = version;
|
| -}
|
| -
|
| -void QuicHttpStream::OnSessionClosed(int error, bool port_migration_detected) {
|
| - session_error_ = error;
|
| - port_migration_detected_ = port_migration_detected;
|
| - SaveResponseStatus();
|
| -
|
| - Close(false);
|
| - session_.reset();
|
| -}
|
| -
|
| void QuicHttpStream::OnIOComplete(int rv) {
|
| rv = DoLoop(rv);
|
|
|
| @@ -617,7 +586,7 @@ int QuicHttpStream::DoLoop(int rv) {
|
| int QuicHttpStream::DoRequestStream() {
|
| next_state_ = STATE_REQUEST_STREAM_COMPLETE;
|
| stream_request_ =
|
| - session_->CreateStreamRequest(request_info_->method == "POST");
|
| + session_.CreateStreamRequest(request_info_->method == "POST");
|
| return stream_request_->StartRequest(
|
| base::Bind(&QuicHttpStream::OnIOComplete, weak_factory_.GetWeakPtr()));
|
| }
|
| @@ -765,10 +734,14 @@ int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) {
|
| return ERR_QUIC_PROTOCOL_ERROR;
|
| }
|
| // Put the peer's IP address and port into the response.
|
| - IPEndPoint address = session_->peer_address().impl().socket_address();
|
| + IPEndPoint address;
|
| + int rv = session_.GetPeerAddress(&address);
|
| + if (rv != OK)
|
| + return rv;
|
| +
|
| response_info_->socket_address = HostPortPair::FromIPEndPoint(address);
|
| response_info_->connection_info =
|
| - ConnectionInfoFromQuicVersion(quic_version_);
|
| + ConnectionInfoFromQuicVersion(session_.GetQuicVersion());
|
| response_info_->vary_data.Init(*request_info_,
|
| *response_info_->headers.get());
|
| response_info_->was_alpn_negotiated = true;
|
| @@ -780,7 +753,7 @@ int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) {
|
|
|
| // Populate |connect_timing_| when response headers are received. This should
|
| // take care of 0-RTT where request is sent before handshake is confirmed.
|
| - connect_timing_ = session_->GetConnectTiming();
|
| + connect_timing_ = session_.GetConnectTiming();
|
| return OK;
|
| }
|
|
|
| @@ -843,7 +816,7 @@ int QuicHttpStream::ComputeResponseStatus() const {
|
|
|
| // If the handshake has failed this will be handled by the QuicStreamFactory
|
| // and HttpStreamFactory to mark QUIC as broken if TCP is actually working.
|
| - if (!was_handshake_confirmed_)
|
| + if (!session_.IsCryptoHandshakeConfirmed())
|
| return ERR_QUIC_HANDSHAKE_FAILED;
|
|
|
| // If the session was aborted by a higher layer, simply use that error code.
|
|
|