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

Side by Side Diff: base/metrics/metrics_hashes.cc

Issue 1777223004: Revert of Collect information about failing histogram factory calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/statistics_recorder.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"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/md5.h" 8 #include "base/md5.h"
10 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
11 10
12 namespace base { 11 namespace base {
13 12
14 namespace { 13 namespace {
15 14
16 // Converts the 8-byte prefix of an MD5 hash into a uint64_t value. 15 // Converts the 8-byte prefix of an MD5 hash into a uint64_t value.
17 inline uint64_t DigestToUInt64(const base::MD5Digest& digest) { 16 inline uint64_t DigestToUInt64(const base::MD5Digest& digest) {
18 uint64_t value; 17 uint64_t value;
19 CHECK_GE(sizeof(digest.a), sizeof(value)); 18 DCHECK_GE(sizeof(digest.a), sizeof(value));
20 memcpy(&value, digest.a, sizeof(value)); 19 memcpy(&value, digest.a, sizeof(value));
21 uint64_t hash = base::NetToHost64(value); 20 return 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;
27 } 21 }
28 22
29 } // namespace 23 } // namespace
30 24
31 uint64_t HashMetricName(base::StringPiece name) { 25 uint64_t HashMetricName(base::StringPiece name) {
32 base::MD5Digest digest; 26 base::MD5Digest digest;
33 base::MD5Sum(name.data(), name.size(), &digest); 27 base::MD5Sum(name.data(), name.size(), &digest);
34 return DigestToUInt64(digest); 28 return DigestToUInt64(digest);
35 } 29 }
36 30
37 } // namespace metrics 31 } // namespace metrics
OLDNEW
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/statistics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698