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

Unified Diff: content/child/child_discardable_shared_memory_manager.cc

Issue 1100073004: Adding discardable memory dump provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/child/child_discardable_shared_memory_manager.cc
diff --git a/content/child/child_discardable_shared_memory_manager.cc b/content/child/child_discardable_shared_memory_manager.cc
index 961733170d578d2a5e23057504a4f822be513589..8eceb10023fd451c5d875d2afc38fa11680fd12c 100644
--- a/content/child/child_discardable_shared_memory_manager.cc
+++ b/content/child/child_discardable_shared_memory_manager.cc
@@ -13,6 +13,9 @@
#include "base/process/memory.h"
#include "base/process/process_metrics.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "content/common/child_process_messages.h"
@@ -27,6 +30,8 @@ const size_t kAllocationSize = 32 * 1024 * 1024;
const size_t kAllocationSize = 4 * 1024 * 1024;
#endif
+const char kMemoryDumperFriendlyName[] = "ChildDiscardable";
reveman 2015/04/23 17:32:30 is "Discardable" enough? we're not using the "Chil
ssid 2015/04/24 11:23:04 Done.
+
// Global atomic to generate unique discardable shared memory IDs.
base::StaticAtomicSequenceNumber g_next_discardable_shared_memory_id;
@@ -83,9 +88,13 @@ void SendDeletedDiscardableSharedMemoryMessage(
ChildDiscardableSharedMemoryManager::ChildDiscardableSharedMemoryManager(
ThreadSafeSender* sender)
: heap_(base::GetPageSize()), sender_(sender) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this);
}
ChildDiscardableSharedMemoryManager::~ChildDiscardableSharedMemoryManager() {
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
Primiano Tucci (use gerrit) 2015/04/23 16:11:55 Considering that this is not a singleton, you shou
ssid 2015/04/24 11:23:03 Thanks. done
+ this);
// TODO(reveman): Determine if this DCHECK can be enabled. crbug.com/430533
// DCHECK_EQ(heap_.GetSize(), heap_.GetSizeOfFreeLists());
if (heap_.GetSize())
@@ -289,4 +298,27 @@ void ChildDiscardableSharedMemoryManager::MemoryUsageChanged(
base::Uint64ToString(new_bytes_free));
}
+bool ChildDiscardableSharedMemoryManager::DumpInto(
+ base::trace_event::ProcessMemoryDump* pmd) {
+ DiscardableSharedMemoryHeap::MemoryStatistics stats;
+ heap_.GetMemoryStatistics(&stats);
+ for (size_t segment = 0; segment < stats.segments_stats.size(); segment++) {
+ std::string segment_id = base::StringPrintf("segment_%zu", segment);
reveman 2015/04/23 17:32:30 nit: looking at process_memory_dump.h it seems lik
ssid 2015/04/24 11:23:03 I used '_' in V8 provider. Primiano, WDYT?
+ base::trace_event::MemoryAllocatorDump* segment_dump =
+ pmd->CreateAllocatorDump("child_discardable_memory",
reveman 2015/04/23 17:32:30 nit: is "discardable" enough? omitting "child_" to
ssid 2015/04/24 11:23:03 Yes discardable is enough.
+ segment_id.c_str());
+ segment_dump->set_physical_size_in_bytes(
+ static_cast<int>(stats.segments_stats[segment].size));
+ segment_dump->set_allocated_objects_count(
+ static_cast<int>(stats.segments_stats[segment].num_of_objects));
+ segment_dump->set_allocated_objects_size_in_bytes(
+ static_cast<int>(stats.segments_stats[segment].used_size));
+ }
+ return true;
+}
+
+const char* ChildDiscardableSharedMemoryManager::GetFriendlyName() const {
+ return kMemoryDumperFriendlyName;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698