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

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

Issue 2906723002: Track how often we would attempt to resolve non-'compliant' domain names. (Closed)
Patch Set: Respond to comments. 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/dns_util.h" 5 #include "net/dns/dns_util.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 9
10 #include <cstring> 10 #include <cstring>
11 11
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "net/base/address_list.h" 17 #include "net/base/address_list.h"
18 #include "net/base/url_util.h"
18 #include "net/dns/dns_protocol.h" 19 #include "net/dns/dns_protocol.h"
20 #include "url/url_canon.h"
19 21
20 namespace { 22 namespace {
21 23
22 // RFC 1035, section 2.3.4: labels 63 octets or less. 24 // RFC 1035, section 2.3.4: labels 63 octets or less.
23 // Section 3.1: Each label is represented as a one octet length field followed 25 // Section 3.1: Each label is represented as a one octet length field followed
24 // by that number of octets. 26 // by that number of octets.
25 const int kMaxLabelLength = 63; 27 const int kMaxLabelLength = 63;
26 28
27 } // namespace 29 } // namespace
28 30
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 name[namelen++] = static_cast<char>(labellen); 69 name[namelen++] = static_cast<char>(labellen);
68 memcpy(name + namelen, label, labellen); 70 memcpy(name + namelen, label, labellen);
69 namelen += labellen; 71 namelen += labellen;
70 labellen = 0; 72 labellen = 0;
71 continue; 73 continue;
72 } 74 }
73 if (labellen >= sizeof label) 75 if (labellen >= sizeof label)
74 return false; 76 return false;
75 if (!IsValidHostLabelCharacter(ch, labellen == 0)) { 77 if (!IsValidHostLabelCharacter(ch, labellen == 0)) {
76 // TODO(palmer): In the future, when we can remove support for invalid 78 // TODO(palmer): In the future, when we can remove support for invalid
77 // names, return false here instead (and remove the UMA counter). 79 // names, return false here instead (and remove the Net.Valid*DNSName UMA
80 // counters).
78 valid_name = false; 81 valid_name = false;
79 } 82 }
80 label[labellen++] = ch; 83 label[labellen++] = ch;
81 } 84 }
82 85
83 UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", valid_name); 86 UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", valid_name);
87 if (valid_name) {
88 url::CanonHostInfo info;
89 UMA_HISTOGRAM_BOOLEAN("Net.DNSNameCompliantIfValid",
90 net::IsCanonicalizedHostCompliant(
91 net::CanonicalizeHost(dotted, &info)));
92 }
84 93
85 // Allow empty label at end of name to disable suffix search. 94 // Allow empty label at end of name to disable suffix search.
86 if (labellen) { 95 if (labellen) {
87 if (namelen + labellen + 1 > sizeof name) 96 if (namelen + labellen + 1 > sizeof name)
88 return false; 97 return false;
89 name[namelen++] = static_cast<char>(labellen); 98 name[namelen++] = static_cast<char>(labellen);
90 memcpy(name + namelen, label, labellen); 99 memcpy(name + namelen, label, labellen);
91 namelen += labellen; 100 namelen += labellen;
92 labellen = 0; 101 labellen = 0;
93 } 102 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return DELTA_IDENTICAL; 205 return DELTA_IDENTICAL;
197 else if (same_size && !any_missing) 206 else if (same_size && !any_missing)
198 return DELTA_REORDERED; 207 return DELTA_REORDERED;
199 else if (any_match) 208 else if (any_match)
200 return DELTA_OVERLAP; 209 return DELTA_OVERLAP;
201 else 210 else
202 return DELTA_DISJOINT; 211 return DELTA_DISJOINT;
203 } 212 }
204 213
205 } // namespace net 214 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698