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

Unified Diff: base/memory/shared_memory_dump_provider.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Remove unneeded calls Created 4 years, 1 month 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: base/memory/shared_memory_dump_provider.cc
diff --git a/base/memory/shared_memory_dump_provider.cc b/base/memory/shared_memory_dump_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d4e222b689b9ed13ad7631de53a6ab95f0d319e0
--- /dev/null
+++ b/base/memory/shared_memory_dump_provider.cc
@@ -0,0 +1,43 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/shared_memory_dump_provider.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
+
+namespace base {
+
+SharedMemoryDumpProvider* SharedMemoryDumpProvider::GetInstance() {
+ return base::Singleton<
+ SharedMemoryDumpProvider,
+ base::LeakySingletonTraits<SharedMemoryDumpProvider>>::get();
+}
+
+bool SharedMemoryDumpProvider::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump("shared");
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ total_memory_usage_);
+ return true;
+}
+
+void SharedMemoryDumpProvider::AddSuballocation(
+ trace_event::ProcessMemoryDump* pmd,
+ const trace_event::MemoryAllocatorDumpGuid& source) {
+ pmd->AddSuballocation(source, "shared");
+}
+
+SharedMemoryDumpProvider::SharedMemoryDumpProvider() {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this, "SharedMemoryDumpProvider", base::ThreadTaskRunnerHandle::Get());
+}
+
+SharedMemoryDumpProvider::~SharedMemoryDumpProvider() {}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698