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

Unified Diff: cc/resources/resource_provider.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: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index e7d309db8a964fa061bd76ef29ba3d21fcd78886..e3ed3fd7e081e7a59d4830238fe1bb4219d4ba38 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"
@@ -2120,10 +2121,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);
@@ -2135,14 +2138,20 @@ 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;
}
DCHECK(!guid.empty());
- const int kImportance = 2;
- pmd->CreateSharedGlobalAllocatorDump(guid);
- pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
+ // const int kImportance = 2;
+ if (shared_memory_handle != base::SharedMemory::NULLHandle()) {
+ // TODO(hajimehoshi): Fix this
+ base::SharedMemoryTracker::AddOwnershipEdges(
+ pmd, guid, shared_memory_handle, total_bytes);
+ }
}
return true;

Powered by Google App Engine
This is Rietveld 408576698