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

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

Issue 1476633003: Move HashMetricName to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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 "components/metrics/metrics_hashes.h" 5 #include "base/metrics/metrics_hashes.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 10
11 namespace metrics { 11 namespace base {
12 12
13 namespace { 13 namespace {
14 14
15 // Converts the 8-byte prefix of an MD5 hash into a uint64 value. 15 // Converts the 8-byte prefix of an MD5 hash into a uint64 value.
16 inline uint64 DigestToUInt64(const base::MD5Digest& digest) { 16 inline uint64 DigestToUInt64(const base::MD5Digest& digest) {
17 uint64 value; 17 uint64 value;
18 DCHECK_GE(arraysize(digest.a), sizeof(value)); 18 DCHECK_GE(sizeof(digest.a), sizeof(value));
19 memcpy(&value, digest.a, sizeof(value)); 19 memcpy(&value, digest.a, sizeof(value));
20 return base::HostToNet64(value); 20 return base::NetToHost64(value);
Alexei Svitkine (slow) 2015/11/25 21:05:40 I think it should still be HostToNet64(). Technic
bcwhite 2015/11/25 22:58:26 It's a raw byte-stream of hash that we're converti
21 } 21 }
22 22
23 } // namespace 23 } // namespace
24 24
25 uint64 HashMetricName(const std::string& name) { 25 uint64 HashMetricName(const std::string& name) {
26 base::MD5Digest digest; 26 base::MD5Digest digest;
27 base::MD5Sum(name.c_str(), name.size(), &digest); 27 base::MD5Sum(name.c_str(), name.size(), &digest);
28 return DigestToUInt64(digest); 28 return DigestToUInt64(digest);
29 } 29 }
30 30
31 } // namespace metrics 31 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698