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 3f5dd7c48d0177125c6eb69e26ee4419b34ee1dc..58b81e49f86619ccd30f0415ba74727b1a1d2070 100644 |
--- a/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp |
+++ b/third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp |
@@ -5,8 +5,9 @@ |
#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 "public/platform/WebString.h" |
#include "wtf/Partitions.h" |
namespace blink { |
@@ -23,12 +24,16 @@ String getPartitionDumpName(const char* partitionName) |
return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpName, partitionName); |
} |
+std::string ToStdString(const String& str) { |
+ return std::string(reinterpret_cast<const char*>(str.ascii().data())); |
esprehn
2015/09/28 18:03:14
This cast doesn't make sense, data() is already a
Primiano Tucci (use gerrit)
2015/09/28 19:07:40
Yeah, just a leftover of doing character8() which
|
+} |
+ |
// This class is used to invert the dependency of PartitionAlloc on the |
// PartitionAllocMemoryDumpProvider. This implements an interface that will |
// 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 +47,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 +55,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); |
+ base::trace_event::MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(ToStdString(getPartitionDumpName(partitionName))); |
allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes); |
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->totalActiveBytes); |
allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedBytes); |
@@ -69,7 +73,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); |
+ base::trace_event::MemoryAllocatorDump* allocatorDump = m_memoryDump->CreateAllocatorDump(ToStdString(dumpName)); |
allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes); |
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->activeBytes); |
allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize); |
@@ -90,18 +94,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)); |
+ base::trace_event::MemoryAllocatorDump* partitionsDump = memoryDump->CreateAllocatorDump( |
+ ToStdString(String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName))); |
// 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::format("%s/allocated_objects", kPartitionAllocDumpName)); |
+ base::trace_event::MemoryAllocatorDump* allocatedObjectsDump = memoryDump->CreateAllocatorDump( |
+ ToStdString(String::format("%s/allocated_objects", kPartitionAllocDumpName))); |
allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalActiveBytes()); |
memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->guid()); |