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

Side by Side Diff: net/quic/chromium/quic_chromium_client_session.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
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 <openssl/ssl.h> 7 #include <openssl/ssl.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 QuicClock* clock, 212 QuicClock* clock,
213 TransportSecurityState* transport_security_state, 213 TransportSecurityState* transport_security_state,
214 std::unique_ptr<QuicServerInfo> server_info, 214 std::unique_ptr<QuicServerInfo> server_info,
215 const QuicServerId& server_id, 215 const QuicServerId& server_id,
216 int yield_after_packets, 216 int yield_after_packets,
217 QuicTime::Delta yield_after_duration, 217 QuicTime::Delta yield_after_duration,
218 int cert_verify_flags, 218 int cert_verify_flags,
219 const QuicConfig& config, 219 const QuicConfig& config,
220 QuicCryptoClientConfig* crypto_config, 220 QuicCryptoClientConfig* crypto_config,
221 const char* const connection_description, 221 const char* const connection_description,
222 base::TimeTicks dns_resolution_start_time,
222 base::TimeTicks dns_resolution_end_time, 223 base::TimeTicks dns_resolution_end_time,
223 QuicClientPushPromiseIndex* push_promise_index, 224 QuicClientPushPromiseIndex* push_promise_index,
224 base::TaskRunner* task_runner, 225 base::TaskRunner* task_runner,
225 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, 226 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
226 NetLog* net_log) 227 NetLog* net_log)
227 : QuicClientSessionBase(connection, push_promise_index, config), 228 : QuicClientSessionBase(connection, push_promise_index, config),
228 server_id_(server_id), 229 server_id_(server_id),
229 require_confirmation_(false), 230 require_confirmation_(false),
230 stream_factory_(stream_factory), 231 stream_factory_(stream_factory),
231 transport_security_state_(transport_security_state), 232 transport_security_state_(transport_security_state),
232 server_info_(std::move(server_info)), 233 server_info_(std::move(server_info)),
233 pkp_bypassed_(false), 234 pkp_bypassed_(false),
234 num_total_streams_(0), 235 num_total_streams_(0),
235 task_runner_(task_runner), 236 task_runner_(task_runner),
236 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)), 237 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)),
237 dns_resolution_end_time_(dns_resolution_end_time),
238 logger_(new QuicConnectionLogger(this, 238 logger_(new QuicConnectionLogger(this,
239 connection_description, 239 connection_description,
240 std::move(socket_performance_watcher), 240 std::move(socket_performance_watcher),
241 net_log_)), 241 net_log_)),
242 going_away_(false), 242 going_away_(false),
243 port_migration_detected_(false), 243 port_migration_detected_(false),
244 token_binding_signatures_(kTokenBindingSignatureMapSize), 244 token_binding_signatures_(kTokenBindingSignatureMapSize),
245 streams_pushed_count_(0), 245 streams_pushed_count_(0),
246 streams_pushed_and_claimed_count_(0), 246 streams_pushed_and_claimed_count_(0),
247 migration_pending_(false), 247 migration_pending_(false),
(...skipping 11 matching lines...) Expand all
259 connection->set_creator_debug_delegate(logger_.get()); 259 connection->set_creator_debug_delegate(logger_.get());
260 net_log_.BeginEvent(NetLogEventType::QUIC_SESSION, 260 net_log_.BeginEvent(NetLogEventType::QUIC_SESSION,
261 base::Bind(NetLogQuicClientSessionCallback, &server_id, 261 base::Bind(NetLogQuicClientSessionCallback, &server_id,
262 cert_verify_flags, require_confirmation_)); 262 cert_verify_flags, require_confirmation_));
263 IPEndPoint address; 263 IPEndPoint address;
264 if (socket && socket->GetLocalAddress(&address) == OK && 264 if (socket && socket->GetLocalAddress(&address) == OK &&
265 address.GetFamily() == ADDRESS_FAMILY_IPV6) { 265 address.GetFamily() == ADDRESS_FAMILY_IPV6) {
266 connection->SetMaxPacketLength(connection->max_packet_length() - 266 connection->SetMaxPacketLength(connection->max_packet_length() -
267 kAdditionalOverheadForIPv6); 267 kAdditionalOverheadForIPv6);
268 } 268 }
269 connect_timing_.dns_start = dns_resolution_start_time;
270 connect_timing_.dns_end = dns_resolution_end_time;
269 } 271 }
270 272
271 QuicChromiumClientSession::~QuicChromiumClientSession() { 273 QuicChromiumClientSession::~QuicChromiumClientSession() {
272 if (!dynamic_streams().empty()) 274 if (!dynamic_streams().empty())
273 RecordUnexpectedOpenStreams(DESTRUCTOR); 275 RecordUnexpectedOpenStreams(DESTRUCTOR);
274 if (!observers_.empty()) 276 if (!observers_.empty())
275 RecordUnexpectedObservers(DESTRUCTOR); 277 RecordUnexpectedObservers(DESTRUCTOR);
276 if (!going_away_) 278 if (!going_away_)
277 RecordUnexpectedNotGoingAway(DESTRUCTOR); 279 RecordUnexpectedNotGoingAway(DESTRUCTOR);
278 280
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 if (!SignTokenBindingEkm(key_material, key, out)) 622 if (!SignTokenBindingEkm(key_material, key, out))
621 return ERR_FAILED; 623 return ERR_FAILED;
622 token_binding_signatures_.Put(raw_public_key, *out); 624 token_binding_signatures_.Put(raw_public_key, *out);
623 return OK; 625 return OK;
624 } 626 }
625 627
626 int QuicChromiumClientSession::CryptoConnect( 628 int QuicChromiumClientSession::CryptoConnect(
627 bool require_confirmation, 629 bool require_confirmation,
628 const CompletionCallback& callback) { 630 const CompletionCallback& callback) {
629 require_confirmation_ = require_confirmation; 631 require_confirmation_ = require_confirmation;
630 handshake_start_ = base::TimeTicks::Now(); 632 connect_timing_.connect_start = base::TimeTicks::Now();
631 RecordHandshakeState(STATE_STARTED); 633 RecordHandshakeState(STATE_STARTED);
632 DCHECK(flow_controller()); 634 DCHECK(flow_controller());
633 crypto_stream_->CryptoConnect(); 635 crypto_stream_->CryptoConnect();
634 636
635 if (IsCryptoHandshakeConfirmed()) 637 if (IsCryptoHandshakeConfirmed()) {
638 connect_timing_.connect_end = base::TimeTicks::Now();
636 return OK; 639 return OK;
640 }
637 641
638 // Unless we require handshake confirmation, activate the session if 642 // Unless we require handshake confirmation, activate the session if
639 // we have established initial encryption. 643 // we have established initial encryption.
640 if (!require_confirmation_ && IsEncryptionEstablished()) 644 if (!require_confirmation_ && IsEncryptionEstablished())
641 return OK; 645 return OK;
642 646
643 callback_ = callback; 647 callback_ = callback;
644 return ERR_IO_PENDING; 648 return ERR_IO_PENDING;
645 } 649 }
646 650
647 int QuicChromiumClientSession::ResumeCryptoConnect( 651 int QuicChromiumClientSession::ResumeCryptoConnect(
648 const CompletionCallback& callback) { 652 const CompletionCallback& callback) {
649 if (IsCryptoHandshakeConfirmed()) 653 if (IsCryptoHandshakeConfirmed()) {
654 connect_timing_.connect_end = base::TimeTicks::Now();
650 return OK; 655 return OK;
656 }
651 657
652 if (!connection()->connected()) 658 if (!connection()->connected())
653 return ERR_QUIC_HANDSHAKE_FAILED; 659 return ERR_QUIC_HANDSHAKE_FAILED;
654 660
655 callback_ = callback; 661 callback_ = callback;
656 return ERR_IO_PENDING; 662 return ERR_IO_PENDING;
657 } 663 }
658 664
659 int QuicChromiumClientSession::GetNumSentClientHellos() const { 665 int QuicChromiumClientSession::GetNumSentClientHellos() const {
660 return crypto_stream_->num_sent_client_hellos(); 666 return crypto_stream_->num_sent_client_hellos();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (!callback_.is_null() && 796 if (!callback_.is_null() &&
791 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED || 797 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED ||
792 event == ENCRYPTION_REESTABLISHED)) { 798 event == ENCRYPTION_REESTABLISHED)) {
793 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_ 799 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_
794 // could be called because there are no error events in CryptoHandshakeEvent 800 // could be called because there are no error events in CryptoHandshakeEvent
795 // enum. If error events are added to CryptoHandshakeEvent, then the 801 // enum. If error events are added to CryptoHandshakeEvent, then the
796 // following code needs to changed. 802 // following code needs to changed.
797 base::ResetAndReturn(&callback_).Run(OK); 803 base::ResetAndReturn(&callback_).Run(OK);
798 } 804 }
799 if (event == HANDSHAKE_CONFIRMED) { 805 if (event == HANDSHAKE_CONFIRMED) {
800 UMA_HISTOGRAM_TIMES("Net.QuicSession.HandshakeConfirmedTime", 806 // Update |connect_end| only when handshake is confirmed. This should also
801 base::TimeTicks::Now() - handshake_start_); 807 // take care of any failed 0-RTT request.
808 connect_timing_.connect_end = base::TimeTicks::Now();
809 DCHECK(connect_timing_.connect_start < connect_timing_.connect_end);
810 UMA_HISTOGRAM_TIMES(
811 "Net.QuicSession.HandshakeConfirmedTime",
812 connect_timing_.connect_end - connect_timing_.connect_start);
813
802 if (server_info_) { 814 if (server_info_) {
803 // TODO(rtenneti): Should we delete this histogram? 815 // TODO(rtenneti): Should we delete this histogram?
804 // Track how long it has taken to finish handshake once we start waiting 816 // Track how long it has taken to finish handshake once we start waiting
805 // for reading of QUIC server information from disk cache. We could use 817 // for reading of QUIC server information from disk cache. We could use
806 // this data to compare total time taken if we were to cancel the disk 818 // this data to compare total time taken if we were to cancel the disk
807 // cache read vs waiting for the read to complete. 819 // cache read vs waiting for the read to complete.
808 base::TimeTicks wait_for_data_start_time = 820 base::TimeTicks wait_for_data_start_time =
809 server_info_->wait_for_data_start_time(); 821 server_info_->wait_for_data_start_time();
810 if (!wait_for_data_start_time.is_null()) { 822 if (!wait_for_data_start_time.is_null()) {
811 UMA_HISTOGRAM_TIMES( 823 UMA_HISTOGRAM_TIMES(
812 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime", 824 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime",
813 base::TimeTicks::Now() - wait_for_data_start_time); 825 base::TimeTicks::Now() - wait_for_data_start_time);
814 } 826 }
815 } 827 }
816 // Track how long it has taken to finish handshake after we have finished 828 // Track how long it has taken to finish handshake after we have finished
817 // DNS host resolution. 829 // DNS host resolution.
818 if (!dns_resolution_end_time_.is_null()) { 830 if (!connect_timing_.dns_end.is_null()) {
819 UMA_HISTOGRAM_TIMES( 831 UMA_HISTOGRAM_TIMES(
820 "Net.QuicSession.HostResolution.HandshakeConfirmedTime", 832 "Net.QuicSession.HostResolution.HandshakeConfirmedTime",
821 base::TimeTicks::Now() - dns_resolution_end_time_); 833 base::TimeTicks::Now() - connect_timing_.dns_end);
822 } 834 }
823 835
824 ObserverSet::iterator it = observers_.begin(); 836 ObserverSet::iterator it = observers_.begin();
825 while (it != observers_.end()) { 837 while (it != observers_.end()) {
826 Observer* observer = *it; 838 Observer* observer = *it;
827 ++it; 839 ++it;
828 observer->OnCryptoHandshakeConfirmed(); 840 observer->OnCryptoHandshakeConfirmed();
829 } 841 }
830 if (server_info_) 842 if (server_info_)
831 server_info_->OnExternalCacheHit(); 843 server_info_->OnExternalCacheHit();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 id, promised_id)); 1392 id, promised_id));
1381 } 1393 }
1382 1394
1383 void QuicChromiumClientSession::DeletePromised( 1395 void QuicChromiumClientSession::DeletePromised(
1384 QuicClientPromisedInfo* promised) { 1396 QuicClientPromisedInfo* promised) {
1385 if (IsOpenStream(promised->id())) 1397 if (IsOpenStream(promised->id()))
1386 streams_pushed_and_claimed_count_++; 1398 streams_pushed_and_claimed_count_++;
1387 QuicClientSessionBase::DeletePromised(promised); 1399 QuicClientSessionBase::DeletePromised(promised);
1388 } 1400 }
1389 1401
1402 const LoadTimingInfo::ConnectTiming&
1403 QuicChromiumClientSession::GetConnectTiming() {
1404 connect_timing_.ssl_start = connect_timing_.connect_start;
1405 connect_timing_.ssl_end = connect_timing_.connect_end;
1406 return connect_timing_;
1407 }
1408
1390 } // namespace net 1409 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_chromium_client_session.h ('k') | net/quic/chromium/quic_chromium_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698