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

Side by Side Diff: net/socket/ssl_host_info.cc

Issue 6041004: net: perform a non-A DNS lookup for HTTPS hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing UMA_ Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_host_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/base/dnsrr_resolver.h"
10 #include "net/base/ssl_config_service.h" 12 #include "net/base/ssl_config_service.h"
11 #include "net/base/x509_certificate.h" 13 #include "net/base/x509_certificate.h"
12 #include "net/socket/ssl_client_socket.h" 14 #include "net/socket/ssl_client_socket.h"
13 15
14 namespace net { 16 namespace net {
15 17
16 SSLHostInfo::State::State() 18 SSLHostInfo::State::State()
17 : npn_valid(false), 19 : npn_valid(false),
18 npn_status(SSLClientSocket::kNextProtoUnsupported) { 20 npn_status(SSLClientSocket::kNextProtoUnsupported) {
19 } 21 }
(...skipping 13 matching lines...) Expand all
33 : cert_verification_complete_(false), 35 : cert_verification_complete_(false),
34 cert_verification_error_(ERR_CERT_INVALID), 36 cert_verification_error_(ERR_CERT_INVALID),
35 hostname_(hostname), 37 hostname_(hostname),
36 cert_parsing_failed_(false), 38 cert_parsing_failed_(false),
37 cert_verification_callback_(NULL), 39 cert_verification_callback_(NULL),
38 rev_checking_enabled_(ssl_config.rev_checking_enabled), 40 rev_checking_enabled_(ssl_config.rev_checking_enabled),
39 verify_ev_cert_(ssl_config.verify_ev_cert), 41 verify_ev_cert_(ssl_config.verify_ev_cert),
40 verifier_(cert_verifier), 42 verifier_(cert_verifier),
41 callback_(new CancelableCompletionCallback<SSLHostInfo>( 43 callback_(new CancelableCompletionCallback<SSLHostInfo>(
42 ALLOW_THIS_IN_INITIALIZER_LIST(this), 44 ALLOW_THIS_IN_INITIALIZER_LIST(this),
43 &SSLHostInfo::VerifyCallback)) { 45 &SSLHostInfo::VerifyCallback)),
46 dnsrr_resolver_(NULL),
47 dns_callback_(NULL),
48 dns_handle_(DnsRRResolver::kInvalidHandle) {
44 state_.npn_valid = false; 49 state_.npn_valid = false;
45 } 50 }
46 51
47 SSLHostInfo::~SSLHostInfo() {} 52 SSLHostInfo::~SSLHostInfo() {
53 if (dns_handle_ != DnsRRResolver::kInvalidHandle) {
54 dnsrr_resolver_->CancelResolve(dns_handle_);
55 delete dns_callback_;
56 }
57 }
58
59 void SSLHostInfo::StartDnsLookup(DnsRRResolver* dnsrr_resolver) {
60 #if defined(OS_LINUX)
61 dnsrr_resolver_ = dnsrr_resolver;
62 dns_callback_ = NewCallback(this, &SSLHostInfo::DnsComplete);
63 dns_lookup_start_time_ = base::TimeTicks::Now();
64
65 dns_handle_ = dnsrr_resolver->Resolve(
66 hostname_, kDNS_CAA, DnsRRResolver::FLAG_WANT_DNSSEC, dns_callback_,
67 &dns_response_, 0, BoundNetLog());
68 #endif
69 }
48 70
49 const SSLHostInfo::State& SSLHostInfo::state() const { 71 const SSLHostInfo::State& SSLHostInfo::state() const {
50 return state_; 72 return state_;
51 } 73 }
52 74
53 SSLHostInfo::State* SSLHostInfo::mutable_state() { 75 SSLHostInfo::State* SSLHostInfo::mutable_state() {
54 return &state_; 76 return &state_;
55 } 77 }
56 78
57 bool SSLHostInfo::Parse(const std::string& data) { 79 bool SSLHostInfo::Parse(const std::string& data) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 verification_end_time_ = now; 211 verification_end_time_ = now;
190 cert_verification_complete_ = true; 212 cert_verification_complete_ = true;
191 cert_verification_error_ = rv; 213 cert_verification_error_ = rv;
192 if (cert_verification_callback_) { 214 if (cert_verification_callback_) {
193 CompletionCallback* callback = cert_verification_callback_; 215 CompletionCallback* callback = cert_verification_callback_;
194 cert_verification_callback_ = NULL; 216 cert_verification_callback_ = NULL;
195 callback->Run(rv); 217 callback->Run(rv);
196 } 218 }
197 } 219 }
198 220
221 void SSLHostInfo::DnsComplete(int rv) {
222 dns_handle_ = DnsRRResolver::kInvalidHandle;
223 dns_callback_ = NULL;
224
225 const base::TimeTicks now = base::TimeTicks::Now();
226 const base::TimeDelta elapsed = now - dns_lookup_start_time_;
227 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoDNSLookup", elapsed);
228 }
229
199 SSLHostInfoFactory::~SSLHostInfoFactory() {} 230 SSLHostInfoFactory::~SSLHostInfoFactory() {}
200 231
201 } // namespace net 232 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_host_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698