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

Unified Diff: components/sessions/core/tab_restore_service_helper.cc

Issue 2451583002: Add MDP for TabRestorer.
Patch Set: Created 4 years, 2 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
« no previous file with comments | « components/sessions/core/tab_restore_service_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sessions/core/tab_restore_service_helper.cc
diff --git a/components/sessions/core/tab_restore_service_helper.cc b/components/sessions/core/tab_restore_service_helper.cc
index 841f07594df1dd636831b88046e525ae4c2735eb..72ed43a9317072f6962d911270537352916cb906 100644
--- a/components/sessions/core/tab_restore_service_helper.cc
+++ b/components/sessions/core/tab_restore_service_helper.cc
@@ -4,6 +4,7 @@
#include "components/sessions/core/tab_restore_service_helper.h"
+#include <inttypes.h>
#include <stddef.h>
#include <algorithm>
@@ -13,6 +14,10 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/trace_event/estimate_memory_usage.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "components/sessions/core/live_tab.h"
#include "components/sessions/core/live_tab_context.h"
#include "components/sessions/core/serialized_navigation_entry.h"
@@ -327,6 +332,28 @@ TabRestoreServiceHelper::GetEntryIteratorById(SessionID::id_type id) {
return entries_.end();
}
+bool TabRestoreServiceHelper::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ using base::trace_event::EstimateMemoryUsage;
+ size_t memory_usage = EstimateMemoryUsage(entries_);
+
+ std::string dump_name = base::StringPrintf(
+ "tab_restore/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(this));
+ auto* dump = pmd->CreateAllocatorDump(dump_name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ memory_usage);
+ const char* system_allocator_name =
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->system_allocator_pool_name();
+ if (system_allocator_name) {
+ pmd->AddSuballocation(dump->guid(), system_allocator_name);
+ }
+
+ return true;
+}
+
// static
bool TabRestoreServiceHelper::ValidateEntry(const Entry& entry) {
switch (entry.type) {
« no previous file with comments | « components/sessions/core/tab_restore_service_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698