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

Unified Diff: gpu/command_buffer/service/transfer_buffer_manager.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: gpu/command_buffer/service/transfer_buffer_manager.cc
diff --git a/gpu/command_buffer/service/transfer_buffer_manager.cc b/gpu/command_buffer/service/transfer_buffer_manager.cc
index 8fd4050d04b96b5d0822254913716e5fa7eabe7d..a061f0b39839c8da8ea0b6b27e92cfb20d96a974 100644
--- a/gpu/command_buffer/service/transfer_buffer_manager.cc
+++ b/gpu/command_buffer/service/transfer_buffer_manager.cc
@@ -10,6 +10,7 @@
#include <memory>
#include "base/logging.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/process/process_handle.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -35,7 +36,7 @@ TransferBufferManager::TransferBufferManager(
TransferBufferManager::~TransferBufferManager() {
while (!registered_buffers_.empty()) {
BufferMap::iterator it = registered_buffers_.begin();
- if (it->second->backing()->is_shared()) {
+ if (it->second->backing()->shared_memory()) {
DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
shared_memory_bytes_allocated_ -= it->second->size();
}
@@ -79,7 +80,7 @@ bool TransferBufferManager::RegisterTransferBuffer(
DCHECK(!(reinterpret_cast<uintptr_t>(buffer->memory()) &
(kCommandBufferEntrySize - 1)));
- if (buffer->backing()->is_shared())
+ if (buffer->backing()->shared_memory())
shared_memory_bytes_allocated_ += buffer->size();
registered_buffers_[id] = buffer;
@@ -93,7 +94,7 @@ void TransferBufferManager::DestroyTransferBuffer(int32_t id) {
return;
}
- if (it->second->backing()->is_shared()) {
+ if (it->second->backing()->shared_memory()) {
DCHECK(shared_memory_bytes_allocated_ >= it->second->size());
shared_memory_bytes_allocated_ -= it->second->size();
}
@@ -138,11 +139,15 @@ bool TransferBufferManager::OnMemoryDump(
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, buffer->size());
- if (buffer->backing()->is_shared()) {
+ base::SharedMemory* shared_memory =
+ buffer_entry.second->backing()->shared_memory();
+ if (shared_memory) {
auto guid = GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(),
buffer_id);
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid);
+ base::SharedMemoryTracker::AddOwnershipEdgeToSharedGlobalDump(pmd, guid,
+ shared_memory->handle(), shared_memory->mapped_size());
}
}

Powered by Google App Engine
This is Rietveld 408576698