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

Unified Diff: base/metrics/metrics_hashes.cc

Issue 1719363002: Collect information about failing histogram factory calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 9 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 | « base/metrics/histogram_unittest.cc ('k') | base/metrics/persistent_histogram_allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/metrics_hashes.cc
diff --git a/base/metrics/metrics_hashes.cc b/base/metrics/metrics_hashes.cc
index 5672b06decb2ef2aa51efb5b705692ceaaf4794e..9b604011ff3d4dee26720ed559e800ad79e5c249 100644
--- a/base/metrics/metrics_hashes.cc
+++ b/base/metrics/metrics_hashes.cc
@@ -4,6 +4,7 @@
#include "base/metrics/metrics_hashes.h"
+#include "base/debug/alias.h"
#include "base/logging.h"
#include "base/md5.h"
#include "base/sys_byteorder.h"
@@ -15,16 +16,42 @@ namespace {
// Converts the 8-byte prefix of an MD5 hash into a uint64_t value.
inline uint64_t DigestToUInt64(const base::MD5Digest& digest) {
uint64_t value;
- DCHECK_GE(sizeof(digest.a), sizeof(value));
+ CHECK_GE(sizeof(digest.a), sizeof(value));
memcpy(&value, digest.a, sizeof(value));
- return base::NetToHost64(value);
+ uint64_t hash = base::NetToHost64(value);
+ CHECK_NE(0U, hash);
+ base::debug::Alias(&hash);
+ base::debug::Alias(&value);
+ base::debug::Alias(&digest);
+ return hash;
}
} // namespace
uint64_t HashMetricName(base::StringPiece name) {
- base::MD5Digest digest;
+ base::MD5Digest digest = {{
+ 0x0F, 0x0E, 0x0D, 0x0C, 0x00, 0x0D, 0x0E, 0x02,
+ 0x0D, 0x0E, 0x0A, 0x0D, 0x0B, 0x0E, 0x0E, 0x0F
+ }};
base::MD5Sum(name.data(), name.size(), &digest);
+ CHECK(
+ digest.a[0] != 0x0F ||
+ digest.a[1] != 0x0E ||
+ digest.a[2] != 0x0D ||
+ digest.a[3] != 0x0C ||
+ digest.a[4] != 0x00 ||
+ digest.a[5] != 0x0D ||
+ digest.a[6] != 0x0E ||
+ digest.a[7] != 0x02 ||
+ digest.a[8] != 0x0D ||
+ digest.a[9] != 0x0E ||
+ digest.a[10] != 0x0A ||
+ digest.a[11] != 0x0D ||
+ digest.a[12] != 0x0B ||
+ digest.a[13] != 0x0E ||
+ digest.a[14] != 0x0E ||
+ digest.a[15] != 0x0F);
+ base::debug::Alias(&name);
return DigestToUInt64(digest);
}
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/persistent_histogram_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698