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

Unified Diff: cc/resources/resource_provider.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Implement buckets Created 3 years, 11 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: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 6547109d3a5f35a9a409073f1a0bc3d6b93041c2..9957cf744a416074ea63c2fe46edece3b3b21dd5 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -13,6 +13,7 @@
#include "base/atomic_sequence_num.h"
#include "base/macros.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/metrics/histogram.h"
#include "base/numerics/safe_math.h"
#include "base/stl_util.h"
@@ -2127,10 +2128,12 @@ bool ResourceProvider::OnMemoryDump(
// Resources may be shared across processes and require a shared GUID to
// prevent double counting the memory.
base::trace_event::MemoryAllocatorDumpGuid guid;
+ base::SharedMemoryHandle shared_memory_handle;
switch (resource.type) {
case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
guid = gfx::GetGpuMemoryBufferGUIDForTracing(
tracing_process_id, resource.gpu_memory_buffer->GetHandle().id);
+ shared_memory_handle = resource.gpu_memory_buffer->GetHandle().handle;
break;
case RESOURCE_TYPE_GL_TEXTURE:
DCHECK(resource.gl_id);
@@ -2142,6 +2145,9 @@ bool ResourceProvider::OnMemoryDump(
case RESOURCE_TYPE_BITMAP:
DCHECK(resource.has_shared_bitmap_id);
guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap_id);
+ auto shared_memory = resource.shared_bitmap->shared_memory();
+ if (shared_memory)
+ shared_memory_handle = shared_memory->handle();
break;
}
@@ -2150,6 +2156,10 @@ bool ResourceProvider::OnMemoryDump(
const int kImportance = 2;
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
+ if (shared_memory_handle != base::SharedMemory::NULLHandle()) {
+ base::SharedMemoryTracker::AddOwnershipEdgeToSharedGlobalDump(
+ pmd, guid, shared_memory_handle, total_bytes);
+ }
}
return true;

Powered by Google App Engine
This is Rietveld 408576698