| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/chromium/quic_http_stream.h" | 5 #include "net/quic/chromium/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 NetLogCaptureMode capture_mode) { | 38 NetLogCaptureMode capture_mode) { |
| 39 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 39 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 40 dict->SetInteger("stream_id", stream_id); | 40 dict->SetInteger("stream_id", stream_id); |
| 41 dict->SetString("url", url->spec()); | 41 dict->SetString("url", url->spec()); |
| 42 return std::move(dict); | 42 return std::move(dict); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 QuicHttpStream::QuicHttpStream( | 47 QuicHttpStream::QuicHttpStream( |
| 48 const base::WeakPtr<QuicChromiumClientSession>& session) | 48 const base::WeakPtr<QuicChromiumClientSession>& session, |
| 49 HttpServerProperties* http_server_properties) |
| 49 : MultiplexedHttpStream(MultiplexedSessionHandle(session)), | 50 : MultiplexedHttpStream(MultiplexedSessionHandle(session)), |
| 50 next_state_(STATE_NONE), | 51 next_state_(STATE_NONE), |
| 51 session_(session), | 52 session_(session), |
| 53 http_server_properties_(http_server_properties), |
| 52 quic_version_(session->GetQuicVersion()), | 54 quic_version_(session->GetQuicVersion()), |
| 53 session_error_(OK), | 55 session_error_(OK), |
| 54 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), | 56 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), |
| 55 stream_(nullptr), | 57 stream_(nullptr), |
| 56 request_info_(nullptr), | 58 request_info_(nullptr), |
| 57 request_body_stream_(nullptr), | 59 request_body_stream_(nullptr), |
| 58 priority_(MINIMUM_PRIORITY), | 60 priority_(MINIMUM_PRIORITY), |
| 59 response_info_(nullptr), | 61 response_info_(nullptr), |
| 60 response_status_(OK), | 62 response_status_(OK), |
| 61 response_headers_received_(false), | 63 response_headers_received_(false), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 NOTREACHED(); | 152 NOTREACHED(); |
| 151 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION; | 153 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION; |
| 152 } | 154 } |
| 153 | 155 |
| 154 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, | 156 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, |
| 155 RequestPriority priority, | 157 RequestPriority priority, |
| 156 const NetLogWithSource& stream_net_log, | 158 const NetLogWithSource& stream_net_log, |
| 157 const CompletionCallback& callback) { | 159 const CompletionCallback& callback) { |
| 158 CHECK(callback_.is_null()); | 160 CHECK(callback_.is_null()); |
| 159 DCHECK(!stream_); | 161 DCHECK(!stream_); |
| 162 |
| 163 // HttpNetworkTransaction will retry any request that fails with |
| 164 // ERR_QUIC_HANDSHAKE_FAILED. It will retry any request with |
| 165 // ERR_CONNECTION_CLOSED so long as the connection has been used for other |
| 166 // streams first and headers have not yet been received. |
| 160 if (!session_) | 167 if (!session_) |
| 161 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 168 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
| 162 : ERR_QUIC_HANDSHAKE_FAILED; | 169 : ERR_QUIC_HANDSHAKE_FAILED; |
| 163 | 170 |
| 164 stream_net_log.AddEvent( | 171 stream_net_log.AddEvent( |
| 165 NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_QUIC_SESSION, | 172 NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_QUIC_SESSION, |
| 166 session_->net_log().source().ToEventParametersCallback()); | 173 session_->net_log().source().ToEventParametersCallback()); |
| 167 | 174 |
| 168 stream_net_log_ = stream_net_log; | 175 stream_net_log_ = stream_net_log; |
| 169 request_info_ = request_info; | 176 request_info_ = request_info; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // TODO(rch): remove this once we figure out why channel ID is not being | 250 // TODO(rch): remove this once we figure out why channel ID is not being |
| 244 // sent when it should be. | 251 // sent when it should be. |
| 245 HostPortPair origin = HostPortPair::FromURL(request_info_->url); | 252 HostPortPair origin = HostPortPair::FromURL(request_info_->url); |
| 246 if (origin.Equals(HostPortPair("accounts.google.com", 443)) && | 253 if (origin.Equals(HostPortPair("accounts.google.com", 443)) && |
| 247 request_headers.HasHeader(HttpRequestHeaders::kCookie)) { | 254 request_headers.HasHeader(HttpRequestHeaders::kCookie)) { |
| 248 SSLInfo ssl_info; | 255 SSLInfo ssl_info; |
| 249 GetSSLInfo(&ssl_info); | 256 GetSSLInfo(&ssl_info); |
| 250 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.CookieSentToAccountsOverChannelId", | 257 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.CookieSentToAccountsOverChannelId", |
| 251 ssl_info.channel_id_sent); | 258 ssl_info.channel_id_sent); |
| 252 } | 259 } |
| 260 |
| 261 // In order to rendezvous with a push stream, the session still needs to be |
| 262 // available. Otherwise the stream needs to be available. |
| 253 if ((!found_promise_ && !stream_) || !session_) { | 263 if ((!found_promise_ && !stream_) || !session_) { |
| 254 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 264 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
| 255 : ERR_QUIC_HANDSHAKE_FAILED; | 265 : ERR_QUIC_HANDSHAKE_FAILED; |
| 256 } | 266 } |
| 257 | 267 |
| 258 // Store the serialized request headers. | 268 // Store the serialized request headers. |
| 259 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, | 269 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, |
| 260 /*direct=*/true, &request_headers_); | 270 /*direct=*/true, &request_headers_); |
| 261 | 271 |
| 262 // Store the request body. | 272 // Store the request body. |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 closed_is_first_stream_ = stream_->IsFirstStream(); | 835 closed_is_first_stream_ = stream_->IsFirstStream(); |
| 826 stream_ = nullptr; | 836 stream_ = nullptr; |
| 827 | 837 |
| 828 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 838 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 829 // read. | 839 // read. |
| 830 if (request_body_stream_) | 840 if (request_body_stream_) |
| 831 request_body_stream_->Reset(); | 841 request_body_stream_->Reset(); |
| 832 } | 842 } |
| 833 | 843 |
| 834 } // namespace net | 844 } // namespace net |
| OLD | NEW |