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

Side by Side Diff: base/trace_event/memory_allocator_dump_guid.cc

Issue 1204573005: [tracing] use SHA1 instead of base::Hash for memory dump GUIDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: zero-copies FTW Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trace_event/memory_allocator_dump_guid.h" 5 #include "base/trace_event/memory_allocator_dump_guid.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/hash.h" 8 #include "base/sha1.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
11 namespace base { 11 namespace base {
12 namespace trace_event { 12 namespace trace_event {
13 13
14 namespace {
15 uint64 HashString(const std::string& str) {
16 uint64 hash[(kSHA1Length + sizeof(uint64) - 1) / sizeof(uint64)] = { 0 };
17 SHA1HashBytes(reinterpret_cast<const unsigned char*>(str.data()), str.size(),
18 reinterpret_cast<unsigned char*>(hash));
19 return hash[0];
20 }
21 } // namespace
22
14 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64 guid) : guid_(guid) { 23 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64 guid) : guid_(guid) {
15 } 24 }
16 25
17 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid() 26 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid()
18 : MemoryAllocatorDumpGuid(0u) { 27 : MemoryAllocatorDumpGuid(0u) {
19 } 28 }
20 29
21 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(const std::string& guid_str) 30 MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(const std::string& guid_str)
22 : MemoryAllocatorDumpGuid(Hash(guid_str)) { 31 : MemoryAllocatorDumpGuid(HashString(guid_str)) {
23 } 32 }
24 33
25 std::string MemoryAllocatorDumpGuid::ToString() const { 34 std::string MemoryAllocatorDumpGuid::ToString() const {
26 return StringPrintf("%" PRIx64, guid_); 35 return StringPrintf("%" PRIx64, guid_);
27 } 36 }
28 37
29 } // namespace trace_event 38 } // namespace trace_event
30 } // namespace base 39 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698