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

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

Issue 2324183002: Implement QuicHttpStream::GetLoadTimingInfo (Closed)
Patch Set: add test 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
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_chromium_client_session.h" 5 #include "net/quic/chromium/quic_chromium_client_session.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 QuicClock* clock, 206 QuicClock* clock,
207 TransportSecurityState* transport_security_state, 207 TransportSecurityState* transport_security_state,
208 std::unique_ptr<QuicServerInfo> server_info, 208 std::unique_ptr<QuicServerInfo> server_info,
209 const QuicServerId& server_id, 209 const QuicServerId& server_id,
210 int yield_after_packets, 210 int yield_after_packets,
211 QuicTime::Delta yield_after_duration, 211 QuicTime::Delta yield_after_duration,
212 int cert_verify_flags, 212 int cert_verify_flags,
213 const QuicConfig& config, 213 const QuicConfig& config,
214 QuicCryptoClientConfig* crypto_config, 214 QuicCryptoClientConfig* crypto_config,
215 const char* const connection_description, 215 const char* const connection_description,
216 base::TimeTicks dns_resolution_start_time,
216 base::TimeTicks dns_resolution_end_time, 217 base::TimeTicks dns_resolution_end_time,
217 QuicClientPushPromiseIndex* push_promise_index, 218 QuicClientPushPromiseIndex* push_promise_index,
218 base::TaskRunner* task_runner, 219 base::TaskRunner* task_runner,
219 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, 220 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
220 NetLog* net_log) 221 NetLog* net_log)
221 : QuicClientSessionBase(connection, push_promise_index, config), 222 : QuicClientSessionBase(connection, push_promise_index, config),
222 server_id_(server_id), 223 server_id_(server_id),
223 require_confirmation_(false), 224 require_confirmation_(false),
224 stream_factory_(stream_factory), 225 stream_factory_(stream_factory),
225 transport_security_state_(transport_security_state), 226 transport_security_state_(transport_security_state),
226 server_info_(std::move(server_info)), 227 server_info_(std::move(server_info)),
227 pkp_bypassed_(false), 228 pkp_bypassed_(false),
228 num_total_streams_(0), 229 num_total_streams_(0),
229 task_runner_(task_runner), 230 task_runner_(task_runner),
230 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)), 231 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)),
231 dns_resolution_end_time_(dns_resolution_end_time),
232 logger_(new QuicConnectionLogger(this, 232 logger_(new QuicConnectionLogger(this,
233 connection_description, 233 connection_description,
234 std::move(socket_performance_watcher), 234 std::move(socket_performance_watcher),
235 net_log_)), 235 net_log_)),
236 going_away_(false), 236 going_away_(false),
237 port_migration_detected_(false), 237 port_migration_detected_(false),
238 disabled_reason_(QUIC_DISABLED_NOT), 238 disabled_reason_(QUIC_DISABLED_NOT),
239 token_binding_signatures_(kTokenBindingSignatureMapSize), 239 token_binding_signatures_(kTokenBindingSignatureMapSize),
240 streams_pushed_count_(0), 240 streams_pushed_count_(0),
241 streams_pushed_and_claimed_count_(0), 241 streams_pushed_and_claimed_count_(0),
(...skipping 13 matching lines...) Expand all
255 connection->set_creator_debug_delegate(logger_.get()); 255 connection->set_creator_debug_delegate(logger_.get());
256 net_log_.BeginEvent(NetLogEventType::QUIC_SESSION, 256 net_log_.BeginEvent(NetLogEventType::QUIC_SESSION,
257 base::Bind(NetLogQuicClientSessionCallback, &server_id, 257 base::Bind(NetLogQuicClientSessionCallback, &server_id,
258 cert_verify_flags, require_confirmation_)); 258 cert_verify_flags, require_confirmation_));
259 IPEndPoint address; 259 IPEndPoint address;
260 if (socket && socket->GetLocalAddress(&address) == OK && 260 if (socket && socket->GetLocalAddress(&address) == OK &&
261 address.GetFamily() == ADDRESS_FAMILY_IPV6) { 261 address.GetFamily() == ADDRESS_FAMILY_IPV6) {
262 connection->SetMaxPacketLength(connection->max_packet_length() - 262 connection->SetMaxPacketLength(connection->max_packet_length() -
263 kAdditionalOverheadForIPv6); 263 kAdditionalOverheadForIPv6);
264 } 264 }
265 connect_timing_.dns_start = dns_resolution_start_time;
266 connect_timing_.dns_end = dns_resolution_end_time;
265 } 267 }
266 268
267 QuicChromiumClientSession::~QuicChromiumClientSession() { 269 QuicChromiumClientSession::~QuicChromiumClientSession() {
268 if (!dynamic_streams().empty()) 270 if (!dynamic_streams().empty())
269 RecordUnexpectedOpenStreams(DESTRUCTOR); 271 RecordUnexpectedOpenStreams(DESTRUCTOR);
270 if (!observers_.empty()) 272 if (!observers_.empty())
271 RecordUnexpectedObservers(DESTRUCTOR); 273 RecordUnexpectedObservers(DESTRUCTOR);
272 if (!going_away_) 274 if (!going_away_)
273 RecordUnexpectedNotGoingAway(DESTRUCTOR); 275 RecordUnexpectedNotGoingAway(DESTRUCTOR);
274 276
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return ERR_FAILED; 598 return ERR_FAILED;
597 token_binding_signatures_.Put(raw_public_key, *out); 599 token_binding_signatures_.Put(raw_public_key, *out);
598 return OK; 600 return OK;
599 } 601 }
600 602
601 int QuicChromiumClientSession::CryptoConnect( 603 int QuicChromiumClientSession::CryptoConnect(
602 bool require_confirmation, 604 bool require_confirmation,
603 const CompletionCallback& callback) { 605 const CompletionCallback& callback) {
604 require_confirmation_ = require_confirmation; 606 require_confirmation_ = require_confirmation;
605 handshake_start_ = base::TimeTicks::Now(); 607 handshake_start_ = base::TimeTicks::Now();
608 connect_timing_.connect_start = handshake_start_;
606 RecordHandshakeState(STATE_STARTED); 609 RecordHandshakeState(STATE_STARTED);
607 DCHECK(flow_controller()); 610 DCHECK(flow_controller());
608 crypto_stream_->CryptoConnect(); 611 crypto_stream_->CryptoConnect();
609 612
610 if (IsCryptoHandshakeConfirmed()) 613 if (IsCryptoHandshakeConfirmed()) {
614 connect_timing_.connect_end = base::TimeTicks::Now();
611 return OK; 615 return OK;
616 }
612 617
613 // Unless we require handshake confirmation, activate the session if 618 // Unless we require handshake confirmation, activate the session if
614 // we have established initial encryption. 619 // we have established initial encryption.
615 if (!require_confirmation_ && IsEncryptionEstablished()) 620 if (!require_confirmation_ && IsEncryptionEstablished()) {
621 connect_timing_.connect_end = base::TimeTicks::Now();
Ryan Hamilton 2016/09/09 20:02:49 Do you know what the semantics of connect_end shou
xunjieli 2016/09/09 21:26:59 Done. That's a really good point! I didn't think o
Ryan Hamilton 2016/09/09 22:05:39 This seems reasonable to me. But it's worth keepin
616 return OK; 622 return OK;
623 }
617 624
618 callback_ = callback; 625 callback_ = callback;
619 return ERR_IO_PENDING; 626 return ERR_IO_PENDING;
620 } 627 }
621 628
622 int QuicChromiumClientSession::ResumeCryptoConnect( 629 int QuicChromiumClientSession::ResumeCryptoConnect(
623 const CompletionCallback& callback) { 630 const CompletionCallback& callback) {
624 if (IsCryptoHandshakeConfirmed()) 631 if (IsCryptoHandshakeConfirmed()) {
632 connect_timing_.connect_end = base::TimeTicks::Now();
625 return OK; 633 return OK;
634 }
626 635
627 if (!connection()->connected()) 636 if (!connection()->connected())
628 return ERR_QUIC_HANDSHAKE_FAILED; 637 return ERR_QUIC_HANDSHAKE_FAILED;
629 638
630 callback_ = callback; 639 callback_ = callback;
631 return ERR_IO_PENDING; 640 return ERR_IO_PENDING;
632 } 641 }
633 642
634 int QuicChromiumClientSession::GetNumSentClientHellos() const { 643 int QuicChromiumClientSession::GetNumSentClientHellos() const {
635 return crypto_stream_->num_sent_client_hellos(); 644 return crypto_stream_->num_sent_client_hellos();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 CryptoHandshakeEvent event) { 768 CryptoHandshakeEvent event) {
760 if (stream_factory_ && event == HANDSHAKE_CONFIRMED && 769 if (stream_factory_ && event == HANDSHAKE_CONFIRMED &&
761 (stream_factory_->OnHandshakeConfirmed( 770 (stream_factory_->OnHandshakeConfirmed(
762 this, logger_->ReceivedPacketLossRate()))) { 771 this, logger_->ReceivedPacketLossRate()))) {
763 return; 772 return;
764 } 773 }
765 774
766 if (!callback_.is_null() && 775 if (!callback_.is_null() &&
767 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED || 776 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED ||
768 event == ENCRYPTION_REESTABLISHED)) { 777 event == ENCRYPTION_REESTABLISHED)) {
778 // Update |connect_end_| if CryptoConnect() returned ERR_IO_PENDING.
779 connect_timing_.connect_end = base::TimeTicks::Now();
780
769 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_ 781 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_
770 // could be called because there are no error events in CryptoHandshakeEvent 782 // could be called because there are no error events in CryptoHandshakeEvent
771 // enum. If error events are added to CryptoHandshakeEvent, then the 783 // enum. If error events are added to CryptoHandshakeEvent, then the
772 // following code needs to changed. 784 // following code needs to changed.
773 base::ResetAndReturn(&callback_).Run(OK); 785 base::ResetAndReturn(&callback_).Run(OK);
774 } 786 }
775 if (event == HANDSHAKE_CONFIRMED) { 787 if (event == HANDSHAKE_CONFIRMED) {
776 UMA_HISTOGRAM_TIMES("Net.QuicSession.HandshakeConfirmedTime", 788 UMA_HISTOGRAM_TIMES("Net.QuicSession.HandshakeConfirmedTime",
777 base::TimeTicks::Now() - handshake_start_); 789 base::TimeTicks::Now() - handshake_start_);
778 if (server_info_) { 790 if (server_info_) {
779 // TODO(rtenneti): Should we delete this histogram? 791 // TODO(rtenneti): Should we delete this histogram?
780 // Track how long it has taken to finish handshake once we start waiting 792 // Track how long it has taken to finish handshake once we start waiting
781 // for reading of QUIC server information from disk cache. We could use 793 // for reading of QUIC server information from disk cache. We could use
782 // this data to compare total time taken if we were to cancel the disk 794 // this data to compare total time taken if we were to cancel the disk
783 // cache read vs waiting for the read to complete. 795 // cache read vs waiting for the read to complete.
784 base::TimeTicks wait_for_data_start_time = 796 base::TimeTicks wait_for_data_start_time =
785 server_info_->wait_for_data_start_time(); 797 server_info_->wait_for_data_start_time();
786 if (!wait_for_data_start_time.is_null()) { 798 if (!wait_for_data_start_time.is_null()) {
787 UMA_HISTOGRAM_TIMES( 799 UMA_HISTOGRAM_TIMES(
788 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime", 800 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime",
789 base::TimeTicks::Now() - wait_for_data_start_time); 801 base::TimeTicks::Now() - wait_for_data_start_time);
790 } 802 }
791 } 803 }
792 // Track how long it has taken to finish handshake after we have finished 804 // Track how long it has taken to finish handshake after we have finished
793 // DNS host resolution. 805 // DNS host resolution.
794 if (!dns_resolution_end_time_.is_null()) { 806 if (!connect_timing_.dns_end.is_null()) {
795 UMA_HISTOGRAM_TIMES( 807 UMA_HISTOGRAM_TIMES(
796 "Net.QuicSession.HostResolution.HandshakeConfirmedTime", 808 "Net.QuicSession.HostResolution.HandshakeConfirmedTime",
797 base::TimeTicks::Now() - dns_resolution_end_time_); 809 base::TimeTicks::Now() - connect_timing_.dns_end);
798 } 810 }
799 811
800 ObserverSet::iterator it = observers_.begin(); 812 ObserverSet::iterator it = observers_.begin();
801 while (it != observers_.end()) { 813 while (it != observers_.end()) {
802 Observer* observer = *it; 814 Observer* observer = *it;
803 ++it; 815 ++it;
804 observer->OnCryptoHandshakeConfirmed(); 816 observer->OnCryptoHandshakeConfirmed();
805 } 817 }
806 if (server_info_) 818 if (server_info_)
807 server_info_->OnExternalCacheHit(); 819 server_info_->OnExternalCacheHit();
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 id, promised_id)); 1240 id, promised_id));
1229 } 1241 }
1230 1242
1231 void QuicChromiumClientSession::DeletePromised( 1243 void QuicChromiumClientSession::DeletePromised(
1232 QuicClientPromisedInfo* promised) { 1244 QuicClientPromisedInfo* promised) {
1233 if (IsOpenStream(promised->id())) 1245 if (IsOpenStream(promised->id()))
1234 streams_pushed_and_claimed_count_++; 1246 streams_pushed_and_claimed_count_++;
1235 QuicClientSessionBase::DeletePromised(promised); 1247 QuicClientSessionBase::DeletePromised(promised);
1236 } 1248 }
1237 1249
1250 const LoadTimingInfo::ConnectTiming&
1251 QuicChromiumClientSession::GetConnectTiming() {
1252 connect_timing_.ssl_start = connect_timing_.connect_start;
1253 connect_timing_.ssl_end = connect_timing_.connect_end;
1254 return connect_timing_;
1255 }
1256
1238 } // namespace net 1257 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698