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

Unified Diff: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 1977783002: BlinkGCMemoryDumpProvider should inherit from MemoryDumpProvider directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
diff --git a/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp b/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
index a0f755685c84f7232c01a581cd68e62ee8fcce2a..4fede90e7d509aaa5ed1f7f015a9a66cbaeaece7 100644
--- a/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
+++ b/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
@@ -6,6 +6,8 @@
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
#include "base/trace_event/heap_profiler_allocation_register.h"
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event_memory_overhead.h"
#include "platform/heap/Handle.h"
#include "platform/web_process_memory_dump_impl.h"
@@ -17,18 +19,16 @@
namespace blink {
namespace {
-void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump)
+void dumpMemoryTotals(base::trace_event::ProcessMemoryDump* memoryDump)
{
- String dumpName = String::format("blink_gc");
- WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDump(dumpName);
- allocatorDump->addScalar("size", "bytes", ProcessHeap::totalAllocatedSpace());
+ base::trace_event::MemoryAllocatorDump* allocatorDump = memoryDump->CreateAllocatorDump("blink_gc");
+ allocatorDump->AddScalar("size", "bytes", ProcessHeap::totalAllocatedSpace());
- dumpName.append("/allocated_objects");
- WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(dumpName);
+ base::trace_event::MemoryAllocatorDump* objectsDump = memoryDump->CreateAllocatorDump("blink_gc/allocated_objects");
// ThreadHeap::markedObjectSize() can be underestimated if we're still in the
// process of lazy sweeping.
- objectsDump->addScalar("size", "bytes", ProcessHeap::totalAllocatedObjectSize() + ProcessHeap::totalMarkedObjectSize());
+ objectsDump->AddScalar("size", "bytes", ProcessHeap::totalAllocatedObjectSize() + ProcessHeap::totalMarkedObjectSize());
}
void reportAllocation(Address address, size_t size, const char* typeName)
@@ -53,11 +53,13 @@ BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider()
{
}
-bool BlinkGCMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, blink::WebProcessMemoryDump* memoryDump)
+bool BlinkGCMemoryDumpProvider::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* memoryDump)
{
+ using base::trace_event::MemoryDumpLevelOfDetail;
+ MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail;
// In the case of a detailed dump perform a mark-only GC pass to collect
// more detailed stats.
- if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed)
+ if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED)
ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapshot, BlinkGC::ForcedGC);
dumpMemoryTotals(memoryDump);
@@ -67,7 +69,7 @@ bool BlinkGCMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfD
base::hash_map<base::trace_event::AllocationContext, base::trace_event::AllocationMetrics> metricsByContext;
{
MutexLocker locker(m_allocationRegisterMutex);
- if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
+ if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED) {
for (const auto& allocSize : *m_allocationRegister) {
base::trace_event::AllocationMetrics& metrics = metricsByContext[allocSize.context];
metrics.size += allocSize.size;
@@ -76,22 +78,22 @@ bool BlinkGCMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfD
}
m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
}
- memoryDump->dumpHeapUsage(metricsByContext, overhead, "blink_gc");
+ memoryDump->DumpHeapUsage(metricsByContext, overhead, "blink_gc");
}
// Merge all dumps collected by ThreadHeap::collectGarbage.
- if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed)
- memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get());
+ if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED)
+ memoryDump->TakeAllDumpsFrom(m_currentProcessMemoryDump.get());
return true;
}
-void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled)
+void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled)
{
if (enabled) {
{
MutexLocker locker(m_allocationRegisterMutex);
if (!m_allocationRegister)
- m_allocationRegister = adoptPtr(new base::trace_event::AllocationRegister());
+ m_allocationRegister.reset(new base::trace_event::AllocationRegister());
}
HeapAllocHooks::setAllocationHook(reportAllocation);
HeapAllocHooks::setFreeHook(reportFree);
@@ -102,18 +104,19 @@ void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled)
m_isHeapProfilingEnabled = enabled;
}
-WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForCurrentGC(const String& absoluteName)
+base::trace_event::MemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForCurrentGC(const String& absoluteName)
{
- return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName);
+ // TODO(bashi): Change type name of |absoluteName|.
+ return m_currentProcessMemoryDump->CreateAllocatorDump(absoluteName.utf8().data());
}
void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC()
{
- m_currentProcessMemoryDump->clear();
+ m_currentProcessMemoryDump->Clear();
}
BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider()
- : m_currentProcessMemoryDump(adoptPtr(new WebProcessMemoryDumpImpl()))
+ : m_currentProcessMemoryDump(new base::trace_event::ProcessMemoryDump(nullptr))
, m_isHeapProfilingEnabled(false)
{
}

Powered by Google App Engine
This is Rietveld 408576698