Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 request_info_(nullptr), | 51 request_info_(nullptr), |
| 52 request_body_stream_(nullptr), | 52 request_body_stream_(nullptr), |
| 53 priority_(MINIMUM_PRIORITY), | 53 priority_(MINIMUM_PRIORITY), |
| 54 response_info_(nullptr), | 54 response_info_(nullptr), |
| 55 response_status_(OK), | 55 response_status_(OK), |
| 56 response_headers_received_(false), | 56 response_headers_received_(false), |
| 57 headers_bytes_received_(0), | 57 headers_bytes_received_(0), |
| 58 headers_bytes_sent_(0), | 58 headers_bytes_sent_(0), |
| 59 closed_stream_received_bytes_(0), | 59 closed_stream_received_bytes_(0), |
| 60 closed_stream_sent_bytes_(0), | 60 closed_stream_sent_bytes_(0), |
| 61 closed_stream_id_(kInvalidStreamId), | |
| 61 user_buffer_len_(0), | 62 user_buffer_len_(0), |
| 62 quic_connection_error_(QUIC_NO_ERROR), | 63 quic_connection_error_(QUIC_NO_ERROR), |
| 63 port_migration_detected_(false), | 64 port_migration_detected_(false), |
| 64 found_promise_(false), | 65 found_promise_(false), |
| 65 push_handle_(nullptr), | 66 push_handle_(nullptr), |
| 66 in_loop_(false), | 67 in_loop_(false), |
| 67 weak_factory_(this) { | 68 weak_factory_(this) { |
| 68 DCHECK(session_); | 69 DCHECK(session_); |
| 69 session_->AddObserver(this); | 70 session_->AddObserver(this); |
| 70 } | 71 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 int64_t total_sent_bytes = headers_bytes_sent_; | 410 int64_t total_sent_bytes = headers_bytes_sent_; |
| 410 if (stream_) { | 411 if (stream_) { |
| 411 total_sent_bytes += stream_->stream_bytes_written(); | 412 total_sent_bytes += stream_->stream_bytes_written(); |
| 412 } else { | 413 } else { |
| 413 total_sent_bytes += closed_stream_sent_bytes_; | 414 total_sent_bytes += closed_stream_sent_bytes_; |
| 414 } | 415 } |
| 415 return total_sent_bytes; | 416 return total_sent_bytes; |
| 416 } | 417 } |
| 417 | 418 |
| 418 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { | 419 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { |
| 419 // TODO(mmenke): Figure out what to do here. | 420 QuicStreamId stream_id = closed_stream_id_; |
| 421 if (stream_) | |
| 422 stream_id = stream_->id(); | |
| 423 if (stream_id == kInvalidStreamId) | |
| 424 return false; | |
| 425 // First stream on a session starts at 5. Any id larger on 5 means session is | |
| 426 // reused. If session is reused, do not populate |connect_timing|. | |
| 427 // FIXME: any constant that I can use to avoid hardcoding 5? | |
|
Ryan Hamilton
2016/09/09 20:02:49
kHeadersStreamId + 2.
But that being said, I thin
xunjieli
2016/09/09 21:26:59
Done. I added a static method to QuicChromiumClien
| |
| 428 if (stream_id > 5) { | |
| 429 load_timing_info->socket_reused = true; | |
| 430 } else { | |
| 431 load_timing_info->connect_timing = connect_timing_; | |
| 432 load_timing_info->socket_reused = false; | |
| 433 } | |
| 420 return true; | 434 return true; |
| 421 } | 435 } |
| 422 | 436 |
| 423 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { | 437 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 424 *ssl_info = ssl_info_; | 438 *ssl_info = ssl_info_; |
| 425 } | 439 } |
| 426 | 440 |
| 427 void QuicHttpStream::GetSSLCertRequestInfo( | 441 void QuicHttpStream::GetSSLCertRequestInfo( |
| 428 SSLCertRequestInfo* cert_request_info) { | 442 SSLCertRequestInfo* cert_request_info) { |
| 429 DCHECK(stream_); | 443 DCHECK(stream_); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 // TODO(rtenneti) Bug: b/28676259 - a temporary fix until we find out why | 648 // TODO(rtenneti) Bug: b/28676259 - a temporary fix until we find out why |
| 635 // |session_| could be a nullptr. Delete |null_session| check and histogram if | 649 // |session_| could be a nullptr. Delete |null_session| check and histogram if |
| 636 // session is never a nullptr. | 650 // session is never a nullptr. |
| 637 bool null_session = session_ == nullptr; | 651 bool null_session = session_ == nullptr; |
| 638 if (null_session) { | 652 if (null_session) { |
| 639 UMA_HISTOGRAM_BOOLEAN("Net.QuicHttpStream::DoStreamRequest.IsNullSession", | 653 UMA_HISTOGRAM_BOOLEAN("Net.QuicHttpStream::DoStreamRequest.IsNullSession", |
| 640 null_session); | 654 null_session); |
| 641 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 655 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
| 642 : ERR_QUIC_HANDSHAKE_FAILED; | 656 : ERR_QUIC_HANDSHAKE_FAILED; |
| 643 } | 657 } |
| 658 connect_timing_ = session_->GetConnectTiming(); | |
| 644 int rv = stream_request_.StartRequest( | 659 int rv = stream_request_.StartRequest( |
| 645 session_, &stream_, | 660 session_, &stream_, |
| 646 base::Bind(&QuicHttpStream::OnStreamReady, weak_factory_.GetWeakPtr())); | 661 base::Bind(&QuicHttpStream::OnStreamReady, weak_factory_.GetWeakPtr())); |
| 647 if (rv == OK) { | 662 if (rv == OK) { |
| 648 stream_->SetDelegate(this); | 663 stream_->SetDelegate(this); |
| 649 if (request_info_->load_flags & LOAD_DISABLE_CONNECTION_MIGRATION) { | 664 if (request_info_->load_flags & LOAD_DISABLE_CONNECTION_MIGRATION) { |
| 650 stream_->DisableConnectionMigration(); | 665 stream_->DisableConnectionMigration(); |
| 651 } | 666 } |
| 652 if (response_info_) { | 667 if (response_info_) { |
| 653 next_state_ = STATE_SET_REQUEST_PRIORITY; | 668 next_state_ = STATE_SET_REQUEST_PRIORITY; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 | 842 |
| 828 void QuicHttpStream::ResetStream() { | 843 void QuicHttpStream::ResetStream() { |
| 829 if (push_handle_) { | 844 if (push_handle_) { |
| 830 push_handle_->Cancel(); | 845 push_handle_->Cancel(); |
| 831 push_handle_ = nullptr; | 846 push_handle_ = nullptr; |
| 832 } | 847 } |
| 833 if (!stream_) | 848 if (!stream_) |
| 834 return; | 849 return; |
| 835 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 850 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 836 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 851 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 852 closed_stream_id_ = stream_->id(); | |
| 837 stream_ = nullptr; | 853 stream_ = nullptr; |
| 838 | 854 |
| 839 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 855 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 840 // read. | 856 // read. |
| 841 if (request_body_stream_) | 857 if (request_body_stream_) |
| 842 request_body_stream_->Reset(); | 858 request_body_stream_->Reset(); |
| 843 } | 859 } |
| 844 | 860 |
| 845 } // namespace net | 861 } // namespace net |
| OLD | NEW |