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

Unified Diff: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp

Issue 1910253003: PartitionAllocMemoryDumpProvider can directly inherit from MemoryDumpProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
diff --git a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
index f9168f482e263b8873c3e5bfe5bc27134164f524..cf318af25d05b1ded5d01104220b2cc010592e91 100644
--- a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
+++ b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
@@ -4,13 +4,12 @@
#include "platform/PartitionAllocMemoryDumpProvider.h"
+#include "base/strings/stringprintf.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
#include "base/trace_event/heap_profiler_allocation_register.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event_memory_overhead.h"
-#include "public/platform/WebMemoryAllocatorDump.h"
-#include "public/platform/WebProcessMemoryDump.h"
#include "wtf/allocator/Partitions.h"
#include "wtf/text/WTFString.h"
@@ -33,9 +32,9 @@ void reportFree(void* address)
const char kPartitionAllocDumpName[] = "partition_alloc";
const char kPartitionsDumpName[] = "partitions";
-String getPartitionDumpName(const char* partitionName)
+std::string getPartitionDumpName(const char* partitionName)
{
- return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpName, partitionName);
+ return base::StringPrintf("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpName, partitionName);
}
// This class is used to invert the dependency of PartitionAlloc on the
@@ -45,7 +44,7 @@ class PartitionStatsDumperImpl final : public PartitionStatsDumper {
DISALLOW_NEW();
WTF_MAKE_NONCOPYABLE(PartitionStatsDumperImpl);
public:
- PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLevelOfDetail levelOfDetail)
+ PartitionStatsDumperImpl(base::trace_event::ProcessMemoryDump* memoryDump, base::trace_event::MemoryDumpLevelOfDetail levelOfDetail)
: m_memoryDump(memoryDump)
, m_uid(0)
, m_totalActiveBytes(0)
@@ -59,7 +58,7 @@ public:
size_t totalActiveBytes() const { return m_totalActiveBytes; }
private:
- WebProcessMemoryDump* m_memoryDump;
+ base::trace_event::ProcessMemoryDump* m_memoryDump;
unsigned long m_uid;
size_t m_totalActiveBytes;
};
@@ -67,36 +66,36 @@ private:
void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, const PartitionMemoryStats* memoryStats)
{
m_totalActiveBytes += memoryStats->totalActiveBytes;
- String dumpName = getPartitionDumpName(partitionName);
- WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
- allocatorDump->addScalar("size", "bytes", memoryStats->totalResidentBytes);
- allocatorDump->addScalar("allocated_objects_size", "bytes", memoryStats->totalActiveBytes);
- allocatorDump->addScalar("virtual_size", "bytes", memoryStats->totalMmappedBytes);
- allocatorDump->addScalar("virtual_committed_size", "bytes", memoryStats->totalCommittedBytes);
- allocatorDump->addScalar("decommittable_size", "bytes", memoryStats->totalDecommittableBytes);
- allocatorDump->addScalar("discardable_size", "bytes", memoryStats->totalDiscardableBytes);
+ std::string dumpName = getPartitionDumpName(partitionName);
+ base::trace_event::MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(dumpName);
+ allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes);
+ allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->totalActiveBytes);
+ allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedBytes);
+ allocatorDump->AddScalar("virtual_committed_size", "bytes", memoryStats->totalCommittedBytes);
+ allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDecommittableBytes);
+ allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->totalDiscardableBytes);
}
void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionName, const PartitionBucketMemoryStats* memoryStats)
{
ASSERT(memoryStats->isValid);
- String dumpName = getPartitionDumpName(partitionName);
+ std::string dumpName = getPartitionDumpName(partitionName);
if (memoryStats->isDirectMap)
- dumpName.append(String::format("/directMap_%lu", ++m_uid));
+ dumpName.append(base::StringPrintf("/directMap_%lu", ++m_uid));
else
- dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memoryStats->bucketSlotSize)));
-
- WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
- allocatorDump->addScalar("size", "bytes", memoryStats->residentBytes);
- allocatorDump->addScalar("allocated_objects_size", "bytes", memoryStats->activeBytes);
- allocatorDump->addScalar("slot_size", "bytes", memoryStats->bucketSlotSize);
- allocatorDump->addScalar("decommittable_size", "bytes", memoryStats->decommittableBytes);
- allocatorDump->addScalar("discardable_size", "bytes", memoryStats->discardableBytes);
- allocatorDump->addScalar("total_pages_size", "bytes", memoryStats->allocatedPageSize);
- allocatorDump->addScalar("active_pages", "objects", memoryStats->numActivePages);
- allocatorDump->addScalar("full_pages", "objects", memoryStats->numFullPages);
- allocatorDump->addScalar("empty_pages", "objects", memoryStats->numEmptyPages);
- allocatorDump->addScalar("decommitted_pages", "objects", memoryStats->numDecommittedPages);
+ dumpName.append(base::StringPrintf("/bucket_%u", static_cast<unsigned>(memoryStats->bucketSlotSize)));
+
+ base::trace_event::MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(dumpName);
+ allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes);
+ allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->activeBytes);
+ allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize);
+ allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommittableBytes);
+ allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardableBytes);
+ allocatorDump->AddScalar("total_pages_size", "bytes", memoryStats->allocatedPageSize);
+ allocatorDump->AddScalar("active_pages", "objects", memoryStats->numActivePages);
+ allocatorDump->AddScalar("full_pages", "objects", memoryStats->numFullPages);
+ allocatorDump->AddScalar("empty_pages", "objects", memoryStats->numEmptyPages);
+ allocatorDump->AddScalar("decommitted_pages", "objects", memoryStats->numDecommittedPages);
}
} // namespace
@@ -107,8 +106,9 @@ PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance()
return &instance;
}
-bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump)
+bool PartitionAllocMemoryDumpProvider::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* memoryDump)
{
+ base::trace_event::MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail;
if (m_isHeapProfilingEnabled) {
// Overhead should always be reported, regardless of light vs. heavy.
base::trace_event::TraceEventMemoryOverhead overhead;
@@ -116,7 +116,7 @@ bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l
{
MutexLocker locker(m_allocationRegisterMutex);
// Dump only the overhead estimation in non-detailed dumps.
- if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
+ if (levelOfDetail == base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {
Primiano Tucci (use gerrit) 2016/04/22 13:05:57 maybe a "using base::trace_event::MemoryDumpLevelO
bashi 2016/04/24 23:33:12 Done.
for (const auto& allocSize : *m_allocationRegister) {
base::trace_event::AllocationMetrics& metrics = metricsByContext[allocSize.context];
metrics.size += allocSize.size;
@@ -125,20 +125,20 @@ bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l
}
m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
}
- memoryDump->dumpHeapUsage(metricsByContext, overhead, "partition_alloc");
+ memoryDump->DumpHeapUsage(metricsByContext, overhead, "partition_alloc");
}
PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
- WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDump(
- String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
+ base::trace_event::MemoryAllocatorDump* partitionsDump = memoryDump->CreateAllocatorDump(
+ base::StringPrintf("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
// This method calls memoryStats.partitionsDumpBucketStats with memory statistics.
- WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail::Light, &partitionStatsDumper);
+ WTF::Partitions::dumpMemoryStats(levelOfDetail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT, &partitionStatsDumper);
- WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAllocatorDump(String(Partitions::kAllocatedObjectPoolName));
- allocatedObjectsDump->addScalar("size", "bytes", partitionStatsDumper.totalActiveBytes());
- memoryDump->addOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->guid());
+ base::trace_event::MemoryAllocatorDump* allocatedObjectsDump = memoryDump->CreateAllocatorDump(Partitions::kAllocatedObjectPoolName);
+ allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalActiveBytes());
+ memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->guid());
return true;
}
@@ -154,13 +154,13 @@ PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider()
{
}
-void PartitionAllocMemoryDumpProvider::onHeapProfilingEnabled(bool enabled)
+void PartitionAllocMemoryDumpProvider::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());
}
PartitionAllocHooks::setAllocationHook(reportAllocation);
PartitionAllocHooks::setFreeHook(reportFree);

Powered by Google App Engine
This is Rietveld 408576698