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

Unified Diff: base/trace_event/memory_allocator_dump_guid.cc

Issue 1173263004: [tracing] Send unique tracing process id for cross-process memory dumps identification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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;
+
+uint64 InsertChildIdAndHash(std::string guid_str) {
+ const char kReplaceChildIdStr[] = "$$";
picksi 2015/06/16 16:18:37 Random thought: Are we ever going to want to add o
ssid 2015/06/19 10:18:14 primiano@ WDYT?
+ size_t pos = guid_str.find(kReplaceChildIdStr);
picksi 2015/06/16 16:18:37 Does this code need to work fast? If so we could a
ssid 2015/06/19 10:18:14 hm, The string length is going to be small, so i d
+ if (pos != std::string::npos) {
+ DCHECK_NE(unique_child_process_id, -1);
+ 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;
}
std::string MemoryAllocatorDumpGuid::ToString() const {

Powered by Google App Engine
This is Rietveld 408576698