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

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

Issue 1099453002: base: Simplify the construction of MD5Digest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 5 years, 8 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
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 "components/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
(...skipping 14 matching lines...) Expand all
25 uint64 HashMetricName(const std::string& name) { 25 uint64 HashMetricName(const std::string& name) {
26 // Create an MD5 hash of the given |name|, represented as a byte buffer 26 // Create an MD5 hash of the given |name|, represented as a byte buffer
27 // encoded as an std::string. 27 // encoded as an std::string.
28 base::MD5Context context; 28 base::MD5Context context;
29 base::MD5Init(&context); 29 base::MD5Init(&context);
30 base::MD5Update(&context, name); 30 base::MD5Update(&context, name);
31 31
32 base::MD5Digest digest; 32 base::MD5Digest digest;
33 base::MD5Final(&digest, &context); 33 base::MD5Final(&digest, &context);
34 34
35 std::string hash_str(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); 35 std::string hash_str(reinterpret_cast<char*>(digest), arraysize(digest));
36 return HashToUInt64(hash_str); 36 return HashToUInt64(hash_str);
37 } 37 }
38 38
39 } // namespace metrics 39 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698