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

Unified Diff: components/discardable_memory/common/discardable_shared_memory_heap.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (wip) Created 3 years, 9 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: components/discardable_memory/common/discardable_shared_memory_heap.cc
diff --git a/components/discardable_memory/common/discardable_shared_memory_heap.cc b/components/discardable_memory/common/discardable_shared_memory_heap.cc
index 7eacbeeec77e03d56bbe2efe6edd459c30cdc4d1..55b334a094567aadec517f67b27279539ac109aa 100644
--- a/components/discardable_memory/common/discardable_shared_memory_heap.cc
+++ b/components/discardable_memory/common/discardable_shared_memory_heap.cc
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/discardable_shared_memory.h"
#include "base/memory/ptr_util.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_dump_manager.h"
@@ -422,36 +423,9 @@ void DiscardableSharedMemoryHeap::OnMemoryDump(
// dumper active and the single ownership edge will become a no-op in the UI.
// The global dump is created as a weak dump so that the segment is removed if
// the browser does not dump it (segment was purged).
- const uint64_t tracing_process_id =
- base::trace_event::MemoryDumpManager::GetInstance()
- ->GetTracingProcessId();
- base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
- GetSegmentGUIDForTracing(tracing_process_id, segment_id);
- // TODO(ssid): Make this weak once the GUID created is consistent
- // crbug.com/661257.
- pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid);
-
- // The size is added to the global dump so that it gets propagated to both the
- // dumps associated.
- pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
- ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
- base::trace_event::MemoryAllocatorDump::kUnitsBytes,
- allocated_objects_size_in_bytes);
-
- // By creating an edge with a higher |importance| (w.r.t. browser-side dumps)
- // the tracing UI will account the effective size of the segment to the
- // client.
- const int kImportance = 2;
- pmd->AddOwnershipEdge(segment_dump->guid(), shared_segment_guid, kImportance);
-}
-
-// static
-base::trace_event::MemoryAllocatorDumpGuid
-DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing(
- uint64_t tracing_process_id,
- int32_t segment_id) {
- return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf(
- "discardable-x-process/%" PRIx64 "/%d", tracing_process_id, segment_id));
+ base::SharedMemoryTracker::AddOwnershipEdges(pmd, segment_dump->guid(),
+ shared_memory->handle(),
+ allocated_objects_size_in_bytes);
}
base::trace_event::MemoryAllocatorDump*

Powered by Google App Engine
This is Rietveld 408576698