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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/metrics/metrics_hashes.h" 5 #include "base/metrics/metrics_hashes.h"
6 6
7 #include "base/debug/alias.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/md5.h" 9 #include "base/md5.h"
9 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 namespace { 14 namespace {
14 15
15 // Converts the 8-byte prefix of an MD5 hash into a uint64_t value. 16 // Converts the 8-byte prefix of an MD5 hash into a uint64_t value.
16 inline uint64_t DigestToUInt64(const base::MD5Digest& digest) { 17 inline uint64_t DigestToUInt64(const base::MD5Digest& digest) {
17 uint64_t value; 18 uint64_t value;
18 DCHECK_GE(sizeof(digest.a), sizeof(value)); 19 CHECK_GE(sizeof(digest.a), sizeof(value));
19 memcpy(&value, digest.a, sizeof(value)); 20 memcpy(&value, digest.a, sizeof(value));
20 return base::NetToHost64(value); 21 uint64_t hash = base::NetToHost64(value);
22 CHECK_NE(0U, hash);
23 base::debug::Alias(&hash);
24 base::debug::Alias(&value);
25 base::debug::Alias(&digest);
26 return hash;
21 } 27 }
22 28
23 } // namespace 29 } // namespace
24 30
25 uint64_t HashMetricName(base::StringPiece name) { 31 uint64_t HashMetricName(base::StringPiece name) {
26 base::MD5Digest digest; 32 base::MD5Digest digest = {{
33 0x0F, 0x0E, 0x0D, 0x0C, 0x00, 0x0D, 0x0E, 0x02,
34 0x0D, 0x0E, 0x0A, 0x0D, 0x0B, 0x0E, 0x0E, 0x0F
35 }};
27 base::MD5Sum(name.data(), name.size(), &digest); 36 base::MD5Sum(name.data(), name.size(), &digest);
37 CHECK(
38 digest.a[0] != 0x0F ||
39 digest.a[1] != 0x0E ||
40 digest.a[2] != 0x0D ||
41 digest.a[3] != 0x0C ||
42 digest.a[4] != 0x00 ||
43 digest.a[5] != 0x0D ||
44 digest.a[6] != 0x0E ||
45 digest.a[7] != 0x02 ||
46 digest.a[8] != 0x0D ||
47 digest.a[9] != 0x0E ||
48 digest.a[10] != 0x0A ||
49 digest.a[11] != 0x0D ||
50 digest.a[12] != 0x0B ||
51 digest.a[13] != 0x0E ||
52 digest.a[14] != 0x0E ||
53 digest.a[15] != 0x0F);
54 base::debug::Alias(&name);
28 return DigestToUInt64(digest); 55 return DigestToUInt64(digest);
29 } 56 }
30 57
31 } // namespace metrics 58 } // namespace metrics
OLDNEW
« 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