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

Unified Diff: net/dns/dns_util.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/dns_util.h ('k') | net/dns/host_resolver_proc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_util.cc
diff --git a/net/dns/dns_util.cc b/net/dns/dns_util.cc
index 06becc2b48b7e223e4ff57243b2c577db868caef..e7844dd8c4f963cffd10735c6b963107a0b64b28 100644
--- a/net/dns/dns_util.cc
+++ b/net/dns/dns_util.cc
@@ -45,7 +45,9 @@ const int kMaxLabelLength = 63;
namespace net {
// Based on DJB's public domain code.
-bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
+bool DNSDomainFromDotWithValidityCheck(const base::StringPiece& dotted,
+ std::string* out,
+ bool* valid_name) {
const char* buf = dotted.data();
size_t n = dotted.size();
char label[kMaxLabelLength];
@@ -53,7 +55,7 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
char name[dns_protocol::kMaxNameLength];
size_t namelen = 0; /* <= sizeof name */
char ch;
- bool valid_name = true;
+ *valid_name = true;
for (;;) {
if (!n)
@@ -75,16 +77,18 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
if (labellen >= sizeof label)
return false;
if (!IsValidHostLabelCharacter(ch, labellen == 0)) {
- // TODO(palmer): In the future, when we can remove support for invalid
- // names, return false here instead (and remove the Net.Valid*DNSName UMA
- // counters).
- valid_name = false;
+ // TODO(crbug.com/695474): In the future, when we can remove support for
+ // invalid names, return false here instead (and remove the UMA counter).
+ // And remove the |valid_name| parameter, rename this function back to
+ // |DNSDomainFromDot|, and remove the helper function by that name
+ // (below).
+ *valid_name = false;
}
label[labellen++] = ch;
}
- UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", valid_name);
- if (valid_name) {
+ UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", *valid_name);
+ if (*valid_name) {
url::CanonHostInfo info;
UMA_HISTOGRAM_BOOLEAN("Net.DNSNameCompliantIfValid",
net::IsCanonicalizedHostCompliant(
@@ -111,6 +115,11 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
return true;
}
+bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
+ bool ignored;
+ return DNSDomainFromDotWithValidityCheck(dotted, out, &ignored);
+}
+
bool IsValidDNSDomain(const base::StringPiece& dotted) {
std::string dns_formatted;
return DNSDomainFromDot(dotted, &dns_formatted);
« no previous file with comments | « net/dns/dns_util.h ('k') | net/dns/host_resolver_proc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698