Chromium Code Reviews| Index: base/trace_event/memory_allocator_dump_guid.cc |
| diff --git a/base/trace_event/memory_allocator_dump_guid.cc b/base/trace_event/memory_allocator_dump_guid.cc |
| index a4ea50d416a0d5bd784e7c74501f77ad45d7b49f..9c770bfa66a212852c8d117c18d0d675fc90979b 100644 |
| --- a/base/trace_event/memory_allocator_dump_guid.cc |
| +++ b/base/trace_event/memory_allocator_dump_guid.cc |
| @@ -6,11 +6,28 @@ |
| #include "base/format_macros.h" |
| #include "base/hash.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/stringprintf.h" |
| namespace base { |
| namespace trace_event { |
| +namespace { |
| +int g_unique_child_process_id = MemoryAllocatorDumpGuid::kInvalidChildProcessId; |
| + |
| +uint64 ExpandChildProcessIdAndHash(std::string guid_str) { |
|
dcheng
2015/06/20 00:36:27
const std::string&
Primiano Tucci (use gerrit)
2015/06/20 12:32:31
Note: the string is mangled below. If he passes a
ssid
2015/06/20 13:07:24
Yes, instead of creating a copy, i passed std::str
|
| + const char kReplaceChildIdStr[] = "$$"; |
| + size_t pos = guid_str.find(kReplaceChildIdStr); |
| + if (pos != std::string::npos) { |
| + DCHECK_NE(g_unique_child_process_id, |
| + MemoryAllocatorDumpGuid::kInvalidChildProcessId); |
| + guid_str.replace(pos, sizeof(kReplaceChildIdStr) - 1, |
| + IntToString(g_unique_child_process_id)); |
| + } |
| + return Hash(guid_str); |
| +} |
| +} // namespace |
| + |
| MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64 guid) : guid_(guid) { |
| } |
| @@ -19,7 +36,14 @@ MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid() |
| } |
| MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(const std::string& guid_str) |
| - : MemoryAllocatorDumpGuid(Hash(guid_str)) { |
| + : MemoryAllocatorDumpGuid(ExpandChildProcessIdAndHash(guid_str)) { |
| +} |
| + |
| +// static |
| +void MemoryAllocatorDumpGuid::SetUniqueChildProcessId(int child_process_id) { |
| + DCHECK(g_unique_child_process_id == kInvalidChildProcessId || |
| + child_process_id == kInvalidChildProcessId); |
| + g_unique_child_process_id = child_process_id; |
| } |
| std::string MemoryAllocatorDumpGuid::ToString() const { |