| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/socket/ssl_host_info.h" | 5 #include "net/socket/ssl_host_info.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "net/base/dns_util.h" | 10 #include "net/base/dns_util.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 const SSLHostInfo::State& SSLHostInfo::state() const { | 71 const SSLHostInfo::State& SSLHostInfo::state() const { |
| 72 return state_; | 72 return state_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 SSLHostInfo::State* SSLHostInfo::mutable_state() { | 75 SSLHostInfo::State* SSLHostInfo::mutable_state() { |
| 76 return &state_; | 76 return &state_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SSLHostInfo::set_cert_verification_finished_time() { |
| 80 #if defined(OS_LINUX) |
| 81 if (dnsrr_resolver_ && dns_handle_ == DnsRRResolver::kInvalidHandle) { |
| 82 // We have completed the DNS lookup already. Therefore, waiting for the DNS |
| 83 // lookup would cause no delay. |
| 84 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookupDelayMs", base::TimeDelta()); |
| 85 } else { |
| 86 // The actual delay will be calculated when the DNS lookup finishes, in |
| 87 // DnsComplete. |
| 88 cert_verification_finished_time_ = base::TimeTicks::Now(); |
| 89 } |
| 90 #endif |
| 91 } |
| 92 |
| 79 bool SSLHostInfo::Parse(const std::string& data) { | 93 bool SSLHostInfo::Parse(const std::string& data) { |
| 80 State* state = mutable_state(); | 94 State* state = mutable_state(); |
| 81 | 95 |
| 82 state->Clear(); | 96 state->Clear(); |
| 83 cert_verification_complete_ = false; | 97 cert_verification_complete_ = false; |
| 84 | 98 |
| 85 bool r = ParseInner(data); | 99 bool r = ParseInner(data); |
| 86 if (!r) | 100 if (!r) |
| 87 state->Clear(); | 101 state->Clear(); |
| 88 return r; | 102 return r; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 callback->Run(rv); | 231 callback->Run(rv); |
| 218 } | 232 } |
| 219 } | 233 } |
| 220 | 234 |
| 221 void SSLHostInfo::DnsComplete(int rv) { | 235 void SSLHostInfo::DnsComplete(int rv) { |
| 222 dns_handle_ = DnsRRResolver::kInvalidHandle; | 236 dns_handle_ = DnsRRResolver::kInvalidHandle; |
| 223 delete dns_callback_; | 237 delete dns_callback_; |
| 224 dns_callback_ = NULL; | 238 dns_callback_ = NULL; |
| 225 | 239 |
| 226 const base::TimeTicks now = base::TimeTicks::Now(); | 240 const base::TimeTicks now = base::TimeTicks::Now(); |
| 227 const base::TimeDelta elapsed = now - dns_lookup_start_time_; | 241 base::TimeDelta elapsed = now - dns_lookup_start_time_; |
| 228 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookup", elapsed); | 242 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookup", elapsed); |
| 243 |
| 244 if (!cert_verification_finished_time_.is_null()) { |
| 245 elapsed = now - cert_verification_finished_time_; |
| 246 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookupDelayMs", elapsed); |
| 247 } |
| 229 } | 248 } |
| 230 | 249 |
| 250 |
| 231 SSLHostInfoFactory::~SSLHostInfoFactory() {} | 251 SSLHostInfoFactory::~SSLHostInfoFactory() {} |
| 232 | 252 |
| 233 } // namespace net | 253 } // namespace net |
| OLD | NEW |