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..2b5c1bba27d07deeb414714e71a997a29689537c 100644 |
| --- a/base/trace_event/memory_allocator_dump_guid.cc |
| +++ b/base/trace_event/memory_allocator_dump_guid.cc |
| @@ -6,9 +6,25 @@ |
| #include "base/format_macros.h" |
| #include "base/hash.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/stringprintf.h" |
| namespace base { |
| +namespace { |
| +int unique_child_process_id = -1; |
|
Primiano Tucci (use gerrit)
2015/06/19 13:47:49
nit: g_ prefix
Add also a kInvalidChildProcessId =
ssid
2015/06/19 14:51:19
Done.
|
| + |
| +uint64 InsertChildIdAndHash(std::string guid_str) { |
|
Primiano Tucci (use gerrit)
2015/06/19 13:47:49
nit: s/InsertChildIdAndHash/ExpandChildProcessIdAn
ssid
2015/06/19 14:51:19
Done.
|
| + const char kReplaceChildIdStr[] = "$$"; |
| + size_t pos = guid_str.find(kReplaceChildIdStr); |
| + if (pos != std::string::npos) { |
| + DCHECK_NE(unique_child_process_id, -1); |
|
Primiano Tucci (use gerrit)
2015/06/19 13:47:49
use kInvalid... instead of -1
ssid
2015/06/19 14:51:19
Done.
|
| + guid_str.replace(pos, sizeof(kReplaceChildIdStr) - 1, |
| + IntToString(unique_child_process_id)); |
| + } |
| + return Hash(guid_str); |
| +} |
| +} // namespace |
| + |
| namespace trace_event { |
| MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64 guid) : guid_(guid) { |
| @@ -19,7 +35,12 @@ MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid() |
| } |
| MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(const std::string& guid_str) |
| - : MemoryAllocatorDumpGuid(Hash(guid_str)) { |
| + : MemoryAllocatorDumpGuid(InsertChildIdAndHash(guid_str)) { |
| +} |
| + |
| +// static |
| +void MemoryAllocatorDumpGuid::SetUniqueChildProcessId(int child_process_id) { |
| + unique_child_process_id = child_process_id; |
|
Primiano Tucci (use gerrit)
2015/06/19 13:47:49
can you add a
DCHECK(child_process_id_ == kInval
ssid
2015/06/19 14:51:19
Done.
|
| } |
| std::string MemoryAllocatorDumpGuid::ToString() const { |