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

Side by Side Diff: net/dns/host_resolver_proc.cc

Issue 2921553002: Track how often we successfully resolve non-'compliant' domain names. (Closed)
Patch Set: |valid_name| is now a pointer! Created 3 years, 6 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
« no previous file with comments | « net/dns/dns_util.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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) 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/dns/host_resolver_proc.h" 5 #include "net/dns/host_resolver_proc.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h"
10 #include "base/sys_byteorder.h" 11 #include "base/sys_byteorder.h"
11 #include "net/base/address_list.h" 12 #include "net/base/address_list.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/base/sys_addrinfo.h" 14 #include "net/base/sys_addrinfo.h"
14 #include "net/dns/dns_reloader.h" 15 #include "net/dns/dns_reloader.h"
15 #include "net/dns/dns_util.h" 16 #include "net/dns/dns_util.h"
16 17
17 #if defined(OS_OPENBSD) 18 #if defined(OS_OPENBSD)
18 #define AI_ADDRCONFIG 0 19 #define AI_ADDRCONFIG 0
19 #endif 20 #endif
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // static 119 // static
119 HostResolverProc* HostResolverProc::GetDefault() { 120 HostResolverProc* HostResolverProc::GetDefault() {
120 return default_proc_; 121 return default_proc_;
121 } 122 }
122 123
123 int SystemHostResolverCall(const std::string& host, 124 int SystemHostResolverCall(const std::string& host,
124 AddressFamily address_family, 125 AddressFamily address_family,
125 HostResolverFlags host_resolver_flags, 126 HostResolverFlags host_resolver_flags,
126 AddressList* addrlist, 127 AddressList* addrlist,
127 int* os_error) { 128 int* os_error) {
128 // Make sure |host| is properly formed. 129 // Make sure |host| is properly formed. Save the validity check result so that
130 // we can count how often invalid names (see |net::IsValidHostLabelCharacter|)
131 // successfully resolve, if ever. TODO(crbug.com/695474): Remove this when we
132 // no longer need the UMA metrics.
133 bool valid_hostname = false;
129 { 134 {
130 std::string out_ignored; 135 std::string out_ignored;
131 if (!DNSDomainFromDot(host, &out_ignored)) 136 if (!DNSDomainFromDotWithValidityCheck(host, &out_ignored, &valid_hostname))
132 return ERR_NAME_NOT_RESOLVED; 137 return ERR_NAME_NOT_RESOLVED;
133 } 138 }
134 139
135 if (os_error) 140 if (os_error)
136 *os_error = 0; 141 *os_error = 0;
137 142
138 struct addrinfo* ai = NULL; 143 struct addrinfo* ai = NULL;
139 struct addrinfo hints = {0}; 144 struct addrinfo hints = {0};
140 145
141 switch (address_family) { 146 switch (address_family) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 251
247 #if defined(OS_ANDROID) 252 #if defined(OS_ANDROID)
248 // Workaround for Android's getaddrinfo leaving ai==NULL without an error. 253 // Workaround for Android's getaddrinfo leaving ai==NULL without an error.
249 // http://crbug.com/134142 254 // http://crbug.com/134142
250 if (ai == NULL) 255 if (ai == NULL)
251 return ERR_NAME_NOT_RESOLVED; 256 return ERR_NAME_NOT_RESOLVED;
252 #endif 257 #endif
253 258
254 *addrlist = AddressList::CreateFromAddrinfo(ai); 259 *addrlist = AddressList::CreateFromAddrinfo(ai);
255 freeaddrinfo(ai); 260 freeaddrinfo(ai);
261 UMA_HISTOGRAM_BOOLEAN("Net.SuccessfulResolutionWithValidDNSName",
262 valid_hostname);
256 return OK; 263 return OK;
257 } 264 }
258 265
259 SystemHostResolverProc::SystemHostResolverProc() : HostResolverProc(NULL) {} 266 SystemHostResolverProc::SystemHostResolverProc() : HostResolverProc(NULL) {}
260 267
261 int SystemHostResolverProc::Resolve(const std::string& hostname, 268 int SystemHostResolverProc::Resolve(const std::string& hostname,
262 AddressFamily address_family, 269 AddressFamily address_family,
263 HostResolverFlags host_resolver_flags, 270 HostResolverFlags host_resolver_flags,
264 AddressList* addr_list, 271 AddressList* addr_list,
265 int* os_error) { 272 int* os_error) {
266 return SystemHostResolverCall(hostname, 273 return SystemHostResolverCall(hostname,
267 address_family, 274 address_family,
268 host_resolver_flags, 275 host_resolver_flags,
269 addr_list, 276 addr_list,
270 os_error); 277 os_error);
271 } 278 }
272 279
273 SystemHostResolverProc::~SystemHostResolverProc() {} 280 SystemHostResolverProc::~SystemHostResolverProc() {}
274 281
275 } // namespace net 282 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_util.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698