summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorprimiano <primiano@chromium.org>2015-10-05 15:49:10 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-05 22:50:09 +0000
commit96baab5ee0a63417a7df22d670692a167eaae98b (patch)
tree6c64087b5e121121b434ba9c9497b43b52c81f6c /base
parent63d8da2dfcb12948f41efc91dbf7ad8a05c3e70d (diff)
downloadchromium_src-96baab5ee0a63417a7df22d670692a167eaae98b.zip
chromium_src-96baab5ee0a63417a7df22d670692a167eaae98b.tar.gz
chromium_src-96baab5ee0a63417a7df22d670692a167eaae98b.tar.bz2
[tracing] Expose a GetOrCreateAllocatorDump for memory tracing
Small non-functional refactor in preparation of upcoming CLs. BUG= TBR=reed@google.com Review URL: https://codereview.chromium.org/1387833004 Cr-Commit-Position: refs/heads/master@{#352453}
Diffstat (limited to 'base')
-rw-r--r--base/trace_event/process_memory_dump.cc8
-rw-r--r--base/trace_event/process_memory_dump.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 67118f1..df26ef5 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -56,6 +56,14 @@ MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
return it == allocator_dumps_.end() ? nullptr : it->second;
}
+MemoryAllocatorDump* ProcessMemoryDump::GetOrCreateAllocatorDump(
+ const std::string& absolute_name) {
+ MemoryAllocatorDump* mad = GetAllocatorDump(absolute_name);
+ if (mad)
+ return mad;
+ return CreateAllocatorDump(absolute_name);
+}
+
MemoryAllocatorDump* ProcessMemoryDump::CreateSharedGlobalAllocatorDump(
const MemoryAllocatorDumpGuid& guid) {
// A shared allocator dump can be shared within a process and the guid could
diff --git a/base/trace_event/process_memory_dump.h b/base/trace_event/process_memory_dump.h
index da18a14..7a16aa4 100644
--- a/base/trace_event/process_memory_dump.h
+++ b/base/trace_event/process_memory_dump.h
@@ -64,6 +64,9 @@ class BASE_EXPORT ProcessMemoryDump {
// nullptr if not found.
MemoryAllocatorDump* GetAllocatorDump(const std::string& absolute_name) const;
+ MemoryAllocatorDump* GetOrCreateAllocatorDump(
+ const std::string& absolute_name);
+
// Creates a shared MemoryAllocatorDump, to express cross-process sharing.
// Shared allocator dumps are allowed to have duplicate guids within the
// global scope, in order to reference the same dump from multiple processes.