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), |
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 bool is_first_stream = closed_is_first_stream_; |
| 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 } |
420 return true; | 429 return true; |
421 } | 430 } |
422 | 431 |
423 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { | 432 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { |
424 *ssl_info = ssl_info_; | 433 *ssl_info = ssl_info_; |
425 } | 434 } |
426 | 435 |
427 void QuicHttpStream::GetSSLCertRequestInfo( | 436 void QuicHttpStream::GetSSLCertRequestInfo( |
428 SSLCertRequestInfo* cert_request_info) { | 437 SSLCertRequestInfo* cert_request_info) { |
429 DCHECK(stream_); | 438 DCHECK(stream_); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 response_info_->connection_info = | 797 response_info_->connection_info = |
789 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; | 798 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; |
790 response_info_->vary_data.Init(*request_info_, | 799 response_info_->vary_data.Init(*request_info_, |
791 *response_info_->headers.get()); | 800 *response_info_->headers.get()); |
792 response_info_->was_npn_negotiated = true; | 801 response_info_->was_npn_negotiated = true; |
793 response_info_->npn_negotiated_protocol = "quic/1+spdy/3"; | 802 response_info_->npn_negotiated_protocol = "quic/1+spdy/3"; |
794 response_info_->response_time = base::Time::Now(); | 803 response_info_->response_time = base::Time::Now(); |
795 response_info_->request_time = request_time_; | 804 response_info_->request_time = request_time_; |
796 response_headers_received_ = true; | 805 response_headers_received_ = true; |
797 | 806 |
| 807 // Populate |connect_timing_| when response headers are received. This should |
| 808 // take care of 0-RTT where request is sent before handshake is confirmed. |
| 809 connect_timing_ = session_->GetConnectTiming(); |
798 return OK; | 810 return OK; |
799 } | 811 } |
800 | 812 |
801 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) { | 813 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) { |
802 int rv = stream_->Read(buf, buf_len); | 814 int rv = stream_->Read(buf, buf_len); |
803 // TODO(rtenneti): Temporary fix for crbug.com/585591. Added a check for null | 815 // TODO(rtenneti): Temporary fix for crbug.com/585591. Added a check for null |
804 // |stream_| to fix crash bug. Delete |stream_| check and histogram after fix | 816 // |stream_| to fix crash bug. Delete |stream_| check and histogram after fix |
805 // is merged. | 817 // is merged. |
806 bool null_stream = stream_ == nullptr; | 818 bool null_stream = stream_ == nullptr; |
807 UMA_HISTOGRAM_BOOLEAN("Net.QuicReadAvailableData.NullStream", null_stream); | 819 UMA_HISTOGRAM_BOOLEAN("Net.QuicReadAvailableData.NullStream", null_stream); |
808 if (null_stream) | 820 if (null_stream) |
809 return rv; | 821 return rv; |
810 if (stream_->IsDoneReading()) { | 822 if (stream_->IsDoneReading()) { |
811 stream_->SetDelegate(nullptr); | 823 stream_->SetDelegate(nullptr); |
812 stream_->OnFinRead(); | 824 stream_->OnFinRead(); |
813 ResetStream(); | 825 ResetStream(); |
814 } | 826 } |
815 return rv; | 827 return rv; |
816 } | 828 } |
817 | 829 |
818 void QuicHttpStream::ResetStream() { | 830 void QuicHttpStream::ResetStream() { |
819 if (push_handle_) { | 831 if (push_handle_) { |
820 push_handle_->Cancel(); | 832 push_handle_->Cancel(); |
821 push_handle_ = nullptr; | 833 push_handle_ = nullptr; |
822 } | 834 } |
823 if (!stream_) | 835 if (!stream_) |
824 return; | 836 return; |
825 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 837 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
826 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 838 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 839 closed_is_first_stream_ = stream_->IsFirstStream(); |
827 stream_ = nullptr; | 840 stream_ = nullptr; |
828 | 841 |
829 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 842 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
830 // read. | 843 // read. |
831 if (request_body_stream_) | 844 if (request_body_stream_) |
832 request_body_stream_->Reset(); | 845 request_body_stream_->Reset(); |
833 } | 846 } |
834 | 847 |
835 } // namespace net | 848 } // namespace net |
OLD | NEW |