Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebMemoryStatistics.cpp |
| diff --git a/third_party/WebKit/Source/web/WebMemoryStatistics.cpp b/third_party/WebKit/Source/web/WebMemoryStatistics.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..95ac46f3f7145619c324c849b0c26d09990e33c4 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/web/WebMemoryStatistics.cpp |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "public/web/WebMemoryStatistics.h" |
| + |
| +#include "platform/heap/Heap.h" |
| +#include "wtf/allocator/Partitions.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +class LightPartitionStatsDumperImpl : public WTF::PartitionStatsDumper { |
| + public: |
| + LightPartitionStatsDumperImpl() : m_totalActiveBytes(0) {} |
| + |
| + void partitionDumpTotals(const char* partitionName, |
| + const WTF::PartitionMemoryStats*) override; |
| + void partitionsDumpBucketStats( |
| + const char* partitionName, |
| + const WTF::PartitionBucketMemoryStats*) override {} |
| + |
| + size_t totalActiveBytes() const { return m_totalActiveBytes; } |
| + |
| + private: |
| + size_t m_totalActiveBytes; |
| +}; |
| + |
| +void LightPartitionStatsDumperImpl::partitionDumpTotals( |
|
haraken
2016/10/06 08:03:17
Nit: Inline this method into the class.
tasak
2016/10/06 09:47:40
Done.
|
| + const char* partitionName, |
| + const WTF::PartitionMemoryStats* memoryStats) { |
| + m_totalActiveBytes += memoryStats->totalActiveBytes; |
| +} |
| +} |
| + |
| +WebMemoryStatistics WebMemoryStatistics::Get() { |
| + LightPartitionStatsDumperImpl dumper; |
| + WebMemoryStatistics statistics; |
| + |
| + WTF::Partitions::dumpMemoryStats(true, &dumper); |
| + statistics.partitionAllocTotalAllocatedBytes = dumper.totalActiveBytes(); |
| + |
| + statistics.blinkGCTotalAllocatedBytes = |
| + ProcessHeap::totalAllocatedObjectSize() + |
| + ProcessHeap::totalMarkedObjectSize(); |
| + return statistics; |
| +} |
| +} |