From 2bbe2d55ce7ac22070c86346a0948435e03707c9 Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Wed, 15 Dec 2010 16:12:41 +0000 Subject: [PATCH] net: fix verification merge savings calculations. Previously we miscalculated the amount of time saved by merging certificate verification. We should have been counting the time from the start of the verification till the time when we needed it because the verification may have completed. In the case that the verification has already completed, only count the amount of time that it took. BUG=none TEST=none http://codereview.chromium.org/5777005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69265 0039d316-1c4b-4281-b951-d872f2087c98 --- net/socket/ssl_client_socket_nss.cc | 6 ++++-- net/socket/ssl_host_info.cc | 2 ++ net/socket/ssl_host_info.h | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 435af0aca7fa8..bbfe12f2dc086 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -2448,9 +2448,11 @@ int SSLClientSocketNSS::DoVerifyCert(int result) { // verification to finish rather than start our own. net_log_.AddEvent(NetLog::TYPE_SSL_VERIFICATION_MERGED, NULL); UMA_HISTOGRAM_ENUMERATION("Net.SSLVerificationMerged", 1 /* true */, 2); - base::TimeTicks now = base::TimeTicks::Now(); + base::TimeTicks end_time = ssl_host_info_->verification_end_time(); + if (end_time.is_null()) + end_time = base::TimeTicks::Now(); UMA_HISTOGRAM_TIMES("Net.SSLVerificationMergedMsSaved", - now - ssl_host_info_->verification_start_time()); + end_time - ssl_host_info_->verification_start_time()); server_cert_verify_result_ = &ssl_host_info_->cert_verify_result(); return ssl_host_info_->WaitForCertVerification(&handshake_io_callback_); } else { diff --git a/net/socket/ssl_host_info.cc b/net/socket/ssl_host_info.cc index 104f0c8428f72..8c1b79fdc7601 100644 --- a/net/socket/ssl_host_info.cc +++ b/net/socket/ssl_host_info.cc @@ -113,6 +113,7 @@ bool SSLHostInfo::ParseInner(const std::string& data) { verifier_.reset(new CertVerifier); VLOG(1) << "Kicking off verification for " << hostname_; verification_start_time_ = base::TimeTicks::Now(); + verification_end_time_ = base::TimeTicks(); if (verifier_->Verify(cert_.get(), hostname_, flags, &cert_verify_result_, callback_) == OK) { VerifyCallback(OK); @@ -185,6 +186,7 @@ void SSLHostInfo::VerifyCallback(int rv) { const base::TimeDelta duration = now - verification_start_time(); UMA_HISTOGRAM_TIMES("Net.SSLHostInfoVerificationTimeMs", duration); VLOG(1) << "Verification took " << duration.InMilliseconds() << "ms"; + verification_end_time_ = now; cert_verification_complete_ = true; cert_verification_error_ = rv; if (cert_verification_callback_) { diff --git a/net/socket/ssl_host_info.h b/net/socket/ssl_host_info.h index 9f579a8fa38c5..782293ec2917b 100644 --- a/net/socket/ssl_host_info.h +++ b/net/socket/ssl_host_info.h @@ -96,6 +96,10 @@ class SSLHostInfo { return verification_start_time_; } + base::TimeTicks verification_end_time() const { + return verification_end_time_; + } + protected: // Parse parses an opaque blob of data and fills out the public member fields // of this object. It returns true iff the parse was successful. The public @@ -121,6 +125,7 @@ class SSLHostInfo { bool rev_checking_enabled_; bool verify_ev_cert_; base::TimeTicks verification_start_time_; + base::TimeTicks verification_end_time_; CertVerifyResult cert_verify_result_; scoped_ptr<CertVerifier> verifier_; scoped_refptr<X509Certificate> cert_; -- GitLab