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

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

Issue 1375643002: [tracing] directly use memory-infra from blink -> base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 2a1bb6381f54f6c960c5d1aad81788f5d5705255..7ba2545722e0e816c8c5f5bc34436029fed436ef 100644
--- a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
+++ b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp
@@ -5,15 +5,17 @@
#include "config.h"
#include "platform/PartitionAllocMemoryDumpProvider.h"
-#include "public/platform/WebMemoryAllocatorDump.h"
-#include "public/platform/WebProcessMemoryDump.h"
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/process_memory_dump.h"
#include "wtf/Partitions.h"
+#include "wtf/text/WTFString.h"
namespace blink {
namespace {
using namespace WTF;
+using base::trace_event::MemoryAllocatorDump;
const char kPartitionAllocDumpName[] = "partition_alloc";
const char kPartitionsDumpName[] = "partitions";
@@ -28,7 +30,7 @@ String getPartitionDumpName(const char* partitionName)
// be called with memory statistics for each bucket in the allocator.
class PartitionStatsDumperImpl final : public PartitionStatsDumper {
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)
@@ -42,7 +44,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;
};
@@ -50,8 +52,7 @@ private:
void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, const PartitionMemoryStats* memoryStats)
{
m_totalActiveBytes += memoryStats->totalActiveBytes;
- String dumpName = getPartitionDumpName(partitionName);
- WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
+ MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(getPartitionDumpName(partitionName).toUTF8StdString());
allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes);
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->totalActiveBytes);
allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedBytes);
@@ -69,7 +70,7 @@ void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa
else
dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memoryStats->bucketSlotSize)));
- WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
+ MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(dumpName.toUTF8StdString());
allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes);
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->activeBytes);
allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize);
@@ -90,18 +91,19 @@ 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)
{
- PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
+ PartitionStatsDumperImpl partitionStatsDumper(memoryDump, args.level_of_detail);
- WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDump(
- String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
+ MemoryAllocatorDump* partitionsDump = memoryDump->CreateAllocatorDump(
+ String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName).toUTF8StdString());
// This method calls memoryStats.partitionsDumpBucketStats with memory statistics.
- WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail::Light, &partitionStatsDumper);
+ WTF::Partitions::dumpMemoryStats(args.level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT, &partitionStatsDumper);
- WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAllocatorDump(String(Partitions::kAllocatedObjectPoolName));
- allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalActiveBytes());
+ MemoryAllocatorDump* allocatedObjectsDump = memoryDump->CreateAllocatorDump(Partitions::kAllocatedObjectPoolName);
+ allocatedObjectsDump->AddScalar(MemoryAllocatorDump::kNameSize, MemoryAllocatorDump::kUnitsBytes, partitionStatsDumper.totalActiveBytes());
memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->guid());
return true;

Powered by Google App Engine
This is Rietveld 408576698