| 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_is_first_stream_(false), | |
| 62 user_buffer_len_(0), | 61 user_buffer_len_(0), |
| 63 quic_connection_error_(QUIC_NO_ERROR), | 62 quic_connection_error_(QUIC_NO_ERROR), |
| 64 port_migration_detected_(false), | 63 port_migration_detected_(false), |
| 65 found_promise_(false), | 64 found_promise_(false), |
| 66 push_handle_(nullptr), | 65 push_handle_(nullptr), |
| 67 in_loop_(false), | 66 in_loop_(false), |
| 68 weak_factory_(this) { | 67 weak_factory_(this) { |
| 69 DCHECK(session_); | 68 DCHECK(session_); |
| 70 session_->AddObserver(this); | 69 session_->AddObserver(this); |
| 71 } | 70 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 int64_t total_sent_bytes = headers_bytes_sent_; | 409 int64_t total_sent_bytes = headers_bytes_sent_; |
| 411 if (stream_) { | 410 if (stream_) { |
| 412 total_sent_bytes += stream_->stream_bytes_written(); | 411 total_sent_bytes += stream_->stream_bytes_written(); |
| 413 } else { | 412 } else { |
| 414 total_sent_bytes += closed_stream_sent_bytes_; | 413 total_sent_bytes += closed_stream_sent_bytes_; |
| 415 } | 414 } |
| 416 return total_sent_bytes; | 415 return total_sent_bytes; |
| 417 } | 416 } |
| 418 | 417 |
| 419 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { | 418 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { |
| 420 bool is_first_stream = closed_is_first_stream_; | 419 // TODO(mmenke): Figure out what to do here. |
| 421 if (stream_) | |
| 422 is_first_stream = stream_->IsFirstStream(); | |
| 423 if (is_first_stream) { | |
| 424 load_timing_info->socket_reused = false; | |
| 425 load_timing_info->connect_timing = connect_timing_; | |
| 426 } else { | |
| 427 load_timing_info->socket_reused = true; | |
| 428 } | |
| 429 return true; | 420 return true; |
| 430 } | 421 } |
| 431 | 422 |
| 432 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { | 423 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 433 *ssl_info = ssl_info_; | 424 *ssl_info = ssl_info_; |
| 434 } | 425 } |
| 435 | 426 |
| 436 void QuicHttpStream::GetSSLCertRequestInfo( | 427 void QuicHttpStream::GetSSLCertRequestInfo( |
| 437 SSLCertRequestInfo* cert_request_info) { | 428 SSLCertRequestInfo* cert_request_info) { |
| 438 DCHECK(stream_); | 429 DCHECK(stream_); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // TODO(rtenneti) Bug: b/28676259 - a temporary fix until we find out why | 634 // TODO(rtenneti) Bug: b/28676259 - a temporary fix until we find out why |
| 644 // |session_| could be a nullptr. Delete |null_session| check and histogram if | 635 // |session_| could be a nullptr. Delete |null_session| check and histogram if |
| 645 // session is never a nullptr. | 636 // session is never a nullptr. |
| 646 bool null_session = session_ == nullptr; | 637 bool null_session = session_ == nullptr; |
| 647 if (null_session) { | 638 if (null_session) { |
| 648 UMA_HISTOGRAM_BOOLEAN("Net.QuicHttpStream::DoStreamRequest.IsNullSession", | 639 UMA_HISTOGRAM_BOOLEAN("Net.QuicHttpStream::DoStreamRequest.IsNullSession", |
| 649 null_session); | 640 null_session); |
| 650 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 641 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
| 651 : ERR_QUIC_HANDSHAKE_FAILED; | 642 : ERR_QUIC_HANDSHAKE_FAILED; |
| 652 } | 643 } |
| 653 connect_timing_ = session_->GetConnectTiming(); | |
| 654 int rv = stream_request_.StartRequest( | 644 int rv = stream_request_.StartRequest( |
| 655 session_, &stream_, | 645 session_, &stream_, |
| 656 base::Bind(&QuicHttpStream::OnStreamReady, weak_factory_.GetWeakPtr())); | 646 base::Bind(&QuicHttpStream::OnStreamReady, weak_factory_.GetWeakPtr())); |
| 657 if (rv == OK) { | 647 if (rv == OK) { |
| 658 stream_->SetDelegate(this); | 648 stream_->SetDelegate(this); |
| 659 if (request_info_->load_flags & LOAD_DISABLE_CONNECTION_MIGRATION) { | 649 if (request_info_->load_flags & LOAD_DISABLE_CONNECTION_MIGRATION) { |
| 660 stream_->DisableConnectionMigration(); | 650 stream_->DisableConnectionMigration(); |
| 661 } | 651 } |
| 662 if (response_info_) { | 652 if (response_info_) { |
| 663 next_state_ = STATE_SET_REQUEST_PRIORITY; | 653 next_state_ = STATE_SET_REQUEST_PRIORITY; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 827 |
| 838 void QuicHttpStream::ResetStream() { | 828 void QuicHttpStream::ResetStream() { |
| 839 if (push_handle_) { | 829 if (push_handle_) { |
| 840 push_handle_->Cancel(); | 830 push_handle_->Cancel(); |
| 841 push_handle_ = nullptr; | 831 push_handle_ = nullptr; |
| 842 } | 832 } |
| 843 if (!stream_) | 833 if (!stream_) |
| 844 return; | 834 return; |
| 845 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 835 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 846 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 836 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 847 closed_is_first_stream_ = stream_->IsFirstStream(); | |
| 848 stream_ = nullptr; | 837 stream_ = nullptr; |
| 849 | 838 |
| 850 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 839 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 851 // read. | 840 // read. |
| 852 if (request_body_stream_) | 841 if (request_body_stream_) |
| 853 request_body_stream_->Reset(); | 842 request_body_stream_->Reset(); |
| 854 } | 843 } |
| 855 | 844 |
| 856 } // namespace net | 845 } // namespace net |
| OLD | NEW |