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

Unified Diff: content/common/host_discardable_shared_memory_manager.cc

Issue 1306243003: Add support to create memory allocator dump in base::DiscardableMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 4 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: content/common/host_discardable_shared_memory_manager.cc
diff --git a/content/common/host_discardable_shared_memory_manager.cc b/content/common/host_discardable_shared_memory_manager.cc
index 7590c1f9bb4c6848f950a21da491494ab04ea0d8..23b1601c772fea2c2adadb7869ee5d93f559adc9 100644
--- a/content/common/host_discardable_shared_memory_manager.cc
+++ b/content/common/host_discardable_shared_memory_manager.cc
@@ -31,8 +31,10 @@ namespace {
class DiscardableMemoryImpl : public base::DiscardableMemory {
public:
DiscardableMemoryImpl(scoped_ptr<base::DiscardableSharedMemory> shared_memory,
+ size_t size,
reveman 2015/08/21 18:05:24 can we use shared_memory->mapped_size() instead?
ssid 2015/08/24 14:52:10 Done.
const base::Closure& deleted_callback)
: shared_memory_(shared_memory.Pass()),
+ size_(size),
deleted_callback_(deleted_callback),
is_locked_(true) {}
@@ -64,8 +66,21 @@ class DiscardableMemoryImpl : public base::DiscardableMemory {
return shared_memory_->memory();
}
+ base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
+ const char* name,
+ base::trace_event::ProcessMemoryDump* pmd) override {
+ // The memory could have been purged by the heap, but we still create a
reveman 2015/08/21 18:05:24 note: there's no heap in this case
ssid 2015/08/24 14:52:10 Done.
+ // dump. So, the size can be inaccurate.
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, size_);
+ return dump;
+ }
+
private:
scoped_ptr<base::DiscardableSharedMemory> shared_memory_;
+ size_t size_;
const base::Closure deleted_callback_;
bool is_locked_;
@@ -147,7 +162,7 @@ HostDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory(
// Close file descriptor to avoid running out.
memory->Close();
return make_scoped_ptr(new DiscardableMemoryImpl(
- memory.Pass(),
+ memory.Pass(), size,
base::Bind(
&HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory,
base::Unretained(this), new_id, ChildProcessHost::kInvalidUniqueID)));

Powered by Google App Engine
This is Rietveld 408576698