Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: net/quic/chromium/quic_http_stream.cc

Issue 2324183002: Implement QuicHttpStream::GetLoadTimingInfo (Closed)
Patch Set: fix flaky TestTwoRequests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 int64_t total_sent_bytes = headers_bytes_sent_; 392 int64_t total_sent_bytes = headers_bytes_sent_;
392 if (stream_) { 393 if (stream_) {
393 total_sent_bytes += stream_->stream_bytes_written(); 394 total_sent_bytes += stream_->stream_bytes_written();
394 } else { 395 } else {
395 total_sent_bytes += closed_stream_sent_bytes_; 396 total_sent_bytes += closed_stream_sent_bytes_;
396 } 397 }
397 return total_sent_bytes; 398 return total_sent_bytes;
398 } 399 }
399 400
400 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { 401 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const {
401 // TODO(mmenke): Figure out what to do here. 402 bool is_first_stream = closed_is_first_stream_;
403 if (stream_)
404 is_first_stream = stream_->IsFirstStream();
405 if (is_first_stream) {
406 load_timing_info->socket_reused = false;
407 load_timing_info->connect_timing = connect_timing_;
408 } else {
409 load_timing_info->socket_reused = true;
410 }
402 return true; 411 return true;
403 } 412 }
404 413
405 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { 414 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) {
406 *ssl_info = ssl_info_; 415 *ssl_info = ssl_info_;
407 } 416 }
408 417
409 void QuicHttpStream::GetSSLCertRequestInfo( 418 void QuicHttpStream::GetSSLCertRequestInfo(
410 SSLCertRequestInfo* cert_request_info) { 419 SSLCertRequestInfo* cert_request_info) {
411 DCHECK(stream_); 420 DCHECK(stream_);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 response_info_->connection_info = 802 response_info_->connection_info =
794 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; 803 HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3;
795 response_info_->vary_data.Init(*request_info_, 804 response_info_->vary_data.Init(*request_info_,
796 *response_info_->headers.get()); 805 *response_info_->headers.get());
797 response_info_->was_npn_negotiated = true; 806 response_info_->was_npn_negotiated = true;
798 response_info_->npn_negotiated_protocol = "quic/1+spdy/3"; 807 response_info_->npn_negotiated_protocol = "quic/1+spdy/3";
799 response_info_->response_time = base::Time::Now(); 808 response_info_->response_time = base::Time::Now();
800 response_info_->request_time = request_time_; 809 response_info_->request_time = request_time_;
801 response_headers_received_ = true; 810 response_headers_received_ = true;
802 811
812 // Populate |connect_timing_| when response headers are received. This should
813 // take care of 0-RTT where request is sent before handshake is confirmed.
814 connect_timing_ = session_->GetConnectTiming();
803 return OK; 815 return OK;
804 } 816 }
805 817
806 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) { 818 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) {
807 int rv = stream_->Read(buf, buf_len); 819 int rv = stream_->Read(buf, buf_len);
808 // TODO(rtenneti): Temporary fix for crbug.com/585591. Added a check for null 820 // TODO(rtenneti): Temporary fix for crbug.com/585591. Added a check for null
809 // |stream_| to fix crash bug. Delete |stream_| check and histogram after fix 821 // |stream_| to fix crash bug. Delete |stream_| check and histogram after fix
810 // is merged. 822 // is merged.
811 bool null_stream = stream_ == nullptr; 823 bool null_stream = stream_ == nullptr;
812 UMA_HISTOGRAM_BOOLEAN("Net.QuicReadAvailableData.NullStream", null_stream); 824 UMA_HISTOGRAM_BOOLEAN("Net.QuicReadAvailableData.NullStream", null_stream);
813 if (null_stream) 825 if (null_stream)
814 return rv; 826 return rv;
815 if (stream_->IsDoneReading()) { 827 if (stream_->IsDoneReading()) {
816 stream_->SetDelegate(nullptr); 828 stream_->SetDelegate(nullptr);
817 stream_->OnFinRead(); 829 stream_->OnFinRead();
818 ResetStream(); 830 ResetStream();
819 } 831 }
820 return rv; 832 return rv;
821 } 833 }
822 834
823 void QuicHttpStream::ResetStream() { 835 void QuicHttpStream::ResetStream() {
824 if (push_handle_) { 836 if (push_handle_) {
825 push_handle_->Cancel(); 837 push_handle_->Cancel();
826 push_handle_ = nullptr; 838 push_handle_ = nullptr;
827 } 839 }
828 if (!stream_) 840 if (!stream_)
829 return; 841 return;
830 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 842 closed_stream_received_bytes_ = stream_->stream_bytes_read();
831 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 843 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
844 closed_is_first_stream_ = stream_->IsFirstStream();
832 stream_ = nullptr; 845 stream_ = nullptr;
833 846
834 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress 847 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress
835 // read. 848 // read.
836 if (request_body_stream_) 849 if (request_body_stream_)
837 request_body_stream_->Reset(); 850 request_body_stream_->Reset();
838 } 851 }
839 852
840 } // namespace net 853 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698