| 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_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 Loading... |
| 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, | |
| 217 base::TimeTicks dns_resolution_end_time, | 216 base::TimeTicks dns_resolution_end_time, |
| 218 QuicClientPushPromiseIndex* push_promise_index, | 217 QuicClientPushPromiseIndex* push_promise_index, |
| 219 base::TaskRunner* task_runner, | 218 base::TaskRunner* task_runner, |
| 220 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 219 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
| 221 NetLog* net_log) | 220 NetLog* net_log) |
| 222 : QuicClientSessionBase(connection, push_promise_index, config), | 221 : QuicClientSessionBase(connection, push_promise_index, config), |
| 223 server_id_(server_id), | 222 server_id_(server_id), |
| 224 require_confirmation_(false), | 223 require_confirmation_(false), |
| 225 stream_factory_(stream_factory), | 224 stream_factory_(stream_factory), |
| 226 transport_security_state_(transport_security_state), | 225 transport_security_state_(transport_security_state), |
| 227 server_info_(std::move(server_info)), | 226 server_info_(std::move(server_info)), |
| 228 pkp_bypassed_(false), | 227 pkp_bypassed_(false), |
| 229 num_total_streams_(0), | 228 num_total_streams_(0), |
| 230 task_runner_(task_runner), | 229 task_runner_(task_runner), |
| 231 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)), | 230 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 Loading... |
| 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; | |
| 267 } | 265 } |
| 268 | 266 |
| 269 QuicChromiumClientSession::~QuicChromiumClientSession() { | 267 QuicChromiumClientSession::~QuicChromiumClientSession() { |
| 270 if (!dynamic_streams().empty()) | 268 if (!dynamic_streams().empty()) |
| 271 RecordUnexpectedOpenStreams(DESTRUCTOR); | 269 RecordUnexpectedOpenStreams(DESTRUCTOR); |
| 272 if (!observers_.empty()) | 270 if (!observers_.empty()) |
| 273 RecordUnexpectedObservers(DESTRUCTOR); | 271 RecordUnexpectedObservers(DESTRUCTOR); |
| 274 if (!going_away_) | 272 if (!going_away_) |
| 275 RecordUnexpectedNotGoingAway(DESTRUCTOR); | 273 RecordUnexpectedNotGoingAway(DESTRUCTOR); |
| 276 | 274 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (!SignTokenBindingEkm(key_material, key, out)) | 595 if (!SignTokenBindingEkm(key_material, key, out)) |
| 598 return ERR_FAILED; | 596 return ERR_FAILED; |
| 599 token_binding_signatures_.Put(raw_public_key, *out); | 597 token_binding_signatures_.Put(raw_public_key, *out); |
| 600 return OK; | 598 return OK; |
| 601 } | 599 } |
| 602 | 600 |
| 603 int QuicChromiumClientSession::CryptoConnect( | 601 int QuicChromiumClientSession::CryptoConnect( |
| 604 bool require_confirmation, | 602 bool require_confirmation, |
| 605 const CompletionCallback& callback) { | 603 const CompletionCallback& callback) { |
| 606 require_confirmation_ = require_confirmation; | 604 require_confirmation_ = require_confirmation; |
| 607 connect_timing_.connect_start = base::TimeTicks::Now(); | 605 handshake_start_ = base::TimeTicks::Now(); |
| 608 RecordHandshakeState(STATE_STARTED); | 606 RecordHandshakeState(STATE_STARTED); |
| 609 DCHECK(flow_controller()); | 607 DCHECK(flow_controller()); |
| 610 crypto_stream_->CryptoConnect(); | 608 crypto_stream_->CryptoConnect(); |
| 611 | 609 |
| 612 if (IsCryptoHandshakeConfirmed()) { | 610 if (IsCryptoHandshakeConfirmed()) |
| 613 connect_timing_.connect_end = base::TimeTicks::Now(); | |
| 614 return OK; | 611 return OK; |
| 615 } | |
| 616 | 612 |
| 617 // Unless we require handshake confirmation, activate the session if | 613 // Unless we require handshake confirmation, activate the session if |
| 618 // we have established initial encryption. | 614 // we have established initial encryption. |
| 619 if (!require_confirmation_ && IsEncryptionEstablished()) | 615 if (!require_confirmation_ && IsEncryptionEstablished()) |
| 620 return OK; | 616 return OK; |
| 621 | 617 |
| 622 callback_ = callback; | 618 callback_ = callback; |
| 623 return ERR_IO_PENDING; | 619 return ERR_IO_PENDING; |
| 624 } | 620 } |
| 625 | 621 |
| 626 int QuicChromiumClientSession::ResumeCryptoConnect( | 622 int QuicChromiumClientSession::ResumeCryptoConnect( |
| 627 const CompletionCallback& callback) { | 623 const CompletionCallback& callback) { |
| 628 if (IsCryptoHandshakeConfirmed()) { | 624 if (IsCryptoHandshakeConfirmed()) |
| 629 connect_timing_.connect_end = base::TimeTicks::Now(); | |
| 630 return OK; | 625 return OK; |
| 631 } | |
| 632 | 626 |
| 633 if (!connection()->connected()) | 627 if (!connection()->connected()) |
| 634 return ERR_QUIC_HANDSHAKE_FAILED; | 628 return ERR_QUIC_HANDSHAKE_FAILED; |
| 635 | 629 |
| 636 callback_ = callback; | 630 callback_ = callback; |
| 637 return ERR_IO_PENDING; | 631 return ERR_IO_PENDING; |
| 638 } | 632 } |
| 639 | 633 |
| 640 int QuicChromiumClientSession::GetNumSentClientHellos() const { | 634 int QuicChromiumClientSession::GetNumSentClientHellos() const { |
| 641 return crypto_stream_->num_sent_client_hellos(); | 635 return crypto_stream_->num_sent_client_hellos(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 if (!callback_.is_null() && | 766 if (!callback_.is_null() && |
| 773 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED || | 767 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED || |
| 774 event == ENCRYPTION_REESTABLISHED)) { | 768 event == ENCRYPTION_REESTABLISHED)) { |
| 775 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_ | 769 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_ |
| 776 // could be called because there are no error events in CryptoHandshakeEvent | 770 // could be called because there are no error events in CryptoHandshakeEvent |
| 777 // enum. If error events are added to CryptoHandshakeEvent, then the | 771 // enum. If error events are added to CryptoHandshakeEvent, then the |
| 778 // following code needs to changed. | 772 // following code needs to changed. |
| 779 base::ResetAndReturn(&callback_).Run(OK); | 773 base::ResetAndReturn(&callback_).Run(OK); |
| 780 } | 774 } |
| 781 if (event == HANDSHAKE_CONFIRMED) { | 775 if (event == HANDSHAKE_CONFIRMED) { |
| 782 // Update |connect_end| only when handshake is confirmed. This should also | 776 UMA_HISTOGRAM_TIMES("Net.QuicSession.HandshakeConfirmedTime", |
| 783 // take care of any failed 0-RTT request. | 777 base::TimeTicks::Now() - handshake_start_); |
| 784 connect_timing_.connect_end = base::TimeTicks::Now(); | |
| 785 DCHECK(connect_timing_.connect_start < connect_timing_.connect_end); | |
| 786 UMA_HISTOGRAM_TIMES( | |
| 787 "Net.QuicSession.HandshakeConfirmedTime", | |
| 788 connect_timing_.connect_end - connect_timing_.connect_start); | |
| 789 | |
| 790 if (server_info_) { | 778 if (server_info_) { |
| 791 // TODO(rtenneti): Should we delete this histogram? | 779 // TODO(rtenneti): Should we delete this histogram? |
| 792 // Track how long it has taken to finish handshake once we start waiting | 780 // Track how long it has taken to finish handshake once we start waiting |
| 793 // for reading of QUIC server information from disk cache. We could use | 781 // for reading of QUIC server information from disk cache. We could use |
| 794 // this data to compare total time taken if we were to cancel the disk | 782 // this data to compare total time taken if we were to cancel the disk |
| 795 // cache read vs waiting for the read to complete. | 783 // cache read vs waiting for the read to complete. |
| 796 base::TimeTicks wait_for_data_start_time = | 784 base::TimeTicks wait_for_data_start_time = |
| 797 server_info_->wait_for_data_start_time(); | 785 server_info_->wait_for_data_start_time(); |
| 798 if (!wait_for_data_start_time.is_null()) { | 786 if (!wait_for_data_start_time.is_null()) { |
| 799 UMA_HISTOGRAM_TIMES( | 787 UMA_HISTOGRAM_TIMES( |
| 800 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime", | 788 "Net.QuicServerInfo.WaitForDataReady.HandshakeConfirmedTime", |
| 801 base::TimeTicks::Now() - wait_for_data_start_time); | 789 base::TimeTicks::Now() - wait_for_data_start_time); |
| 802 } | 790 } |
| 803 } | 791 } |
| 804 // Track how long it has taken to finish handshake after we have finished | 792 // Track how long it has taken to finish handshake after we have finished |
| 805 // DNS host resolution. | 793 // DNS host resolution. |
| 806 if (!connect_timing_.dns_end.is_null()) { | 794 if (!dns_resolution_end_time_.is_null()) { |
| 807 UMA_HISTOGRAM_TIMES( | 795 UMA_HISTOGRAM_TIMES( |
| 808 "Net.QuicSession.HostResolution.HandshakeConfirmedTime", | 796 "Net.QuicSession.HostResolution.HandshakeConfirmedTime", |
| 809 base::TimeTicks::Now() - connect_timing_.dns_end); | 797 base::TimeTicks::Now() - dns_resolution_end_time_); |
| 810 } | 798 } |
| 811 | 799 |
| 812 ObserverSet::iterator it = observers_.begin(); | 800 ObserverSet::iterator it = observers_.begin(); |
| 813 while (it != observers_.end()) { | 801 while (it != observers_.end()) { |
| 814 Observer* observer = *it; | 802 Observer* observer = *it; |
| 815 ++it; | 803 ++it; |
| 816 observer->OnCryptoHandshakeConfirmed(); | 804 observer->OnCryptoHandshakeConfirmed(); |
| 817 } | 805 } |
| 818 if (server_info_) | 806 if (server_info_) |
| 819 server_info_->OnExternalCacheHit(); | 807 server_info_->OnExternalCacheHit(); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 id, promised_id)); | 1228 id, promised_id)); |
| 1241 } | 1229 } |
| 1242 | 1230 |
| 1243 void QuicChromiumClientSession::DeletePromised( | 1231 void QuicChromiumClientSession::DeletePromised( |
| 1244 QuicClientPromisedInfo* promised) { | 1232 QuicClientPromisedInfo* promised) { |
| 1245 if (IsOpenStream(promised->id())) | 1233 if (IsOpenStream(promised->id())) |
| 1246 streams_pushed_and_claimed_count_++; | 1234 streams_pushed_and_claimed_count_++; |
| 1247 QuicClientSessionBase::DeletePromised(promised); | 1235 QuicClientSessionBase::DeletePromised(promised); |
| 1248 } | 1236 } |
| 1249 | 1237 |
| 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 | |
| 1257 } // namespace net | 1238 } // namespace net |
| OLD | NEW |