summaryrefslogtreecommitdiffstats
path: root/net/socket/ssl_host_info.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-06 19:49:43 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-06 19:49:43 +0000
commitc6781deb1f4c33bdefe4126b29052040571f3a27 (patch)
treeafa4214bad63c2bc306d04394bebb5a437698053 /net/socket/ssl_host_info.cc
parent08eafdae4119847cbfda59f4ee5c1288049a8b23 (diff)
downloadchromium_src-c6781deb1f4c33bdefe4126b29052040571f3a27.zip
chromium_src-c6781deb1f4c33bdefe4126b29052040571f3a27.tar.gz
chromium_src-c6781deb1f4c33bdefe4126b29052040571f3a27.tar.bz2
net: perform a non-A DNS lookup for HTTPS hosts.
Since SSLHostInfo is enabled by default now, this will cause a DNS lookup for a random RR type (13172) for each HTTPS host. (Although many of these lookups will hit the in-process cache. Also, this won't do anything on non-Linux machines because I haven't gotten the DNS lookup code working on them yet.) At some point in the future we'll probably want to do these lookups in order to get information for certificate validation. This change just exists so that we can measure how long these lookups take. BUG=none TEST=none http://codereview.chromium.org/6041004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/ssl_host_info.cc')
-rw-r--r--net/socket/ssl_host_info.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/net/socket/ssl_host_info.cc b/net/socket/ssl_host_info.cc
index ccfe7a53..7a8209a 100644
--- a/net/socket/ssl_host_info.cc
+++ b/net/socket/ssl_host_info.cc
@@ -7,6 +7,8 @@
#include "base/metrics/histogram.h"
#include "base/pickle.h"
#include "base/string_piece.h"
+#include "net/base/dns_util.h"
+#include "net/base/dnsrr_resolver.h"
#include "net/base/ssl_config_service.h"
#include "net/base/x509_certificate.h"
#include "net/socket/ssl_client_socket.h"
@@ -40,11 +42,31 @@ SSLHostInfo::SSLHostInfo(
verifier_(cert_verifier),
callback_(new CancelableCompletionCallback<SSLHostInfo>(
ALLOW_THIS_IN_INITIALIZER_LIST(this),
- &SSLHostInfo::VerifyCallback)) {
+ &SSLHostInfo::VerifyCallback)),
+ dnsrr_resolver_(NULL),
+ dns_callback_(NULL),
+ dns_handle_(DnsRRResolver::kInvalidHandle) {
state_.npn_valid = false;
}
-SSLHostInfo::~SSLHostInfo() {}
+SSLHostInfo::~SSLHostInfo() {
+ if (dns_handle_ != DnsRRResolver::kInvalidHandle) {
+ dnsrr_resolver_->CancelResolve(dns_handle_);
+ delete dns_callback_;
+ }
+}
+
+void SSLHostInfo::StartDnsLookup(DnsRRResolver* dnsrr_resolver) {
+#if defined(OS_LINUX)
+ dnsrr_resolver_ = dnsrr_resolver;
+ dns_callback_ = NewCallback(this, &SSLHostInfo::DnsComplete);
+ dns_lookup_start_time_ = base::TimeTicks::Now();
+
+ dns_handle_ = dnsrr_resolver->Resolve(
+ hostname_, kDNS_CAA, DnsRRResolver::FLAG_WANT_DNSSEC, dns_callback_,
+ &dns_response_, 0, BoundNetLog());
+#endif
+}
const SSLHostInfo::State& SSLHostInfo::state() const {
return state_;
@@ -196,6 +218,15 @@ void SSLHostInfo::VerifyCallback(int rv) {
}
}
+void SSLHostInfo::DnsComplete(int rv) {
+ dns_handle_ = DnsRRResolver::kInvalidHandle;
+ dns_callback_ = NULL;
+
+ const base::TimeTicks now = base::TimeTicks::Now();
+ const base::TimeDelta elapsed = now - dns_lookup_start_time_;
+ UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookup", elapsed);
+}
+
SSLHostInfoFactory::~SSLHostInfoFactory() {}
} // namespace net