| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "public/web/WebMemoryStatistics.h" | 5 #include "public/web/WebMemoryStatistics.h" |
| 6 | 6 |
| 7 #include "platform/heap/Heap.h" | 7 #include "platform/heap/Heap.h" |
| 8 #include "wtf/allocator/Partitions.h" | 8 #include "wtf/allocator/Partitions.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class LightPartitionStatsDumperImpl : public WTF::PartitionStatsDumper { | 14 class LightPartitionStatsDumperImpl : public WTF::PartitionStatsDumper { |
| 15 public: | 15 public: |
| 16 LightPartitionStatsDumperImpl() : m_totalActiveBytes(0) {} | 16 LightPartitionStatsDumperImpl() : m_totalActiveBytes(0) {} |
| 17 | 17 |
| 18 void partitionDumpTotals( | 18 void PartitionDumpTotals( |
| 19 const char* partitionName, | 19 const char* partitionName, |
| 20 const WTF::PartitionMemoryStats* memoryStats) override { | 20 const WTF::PartitionMemoryStats* memoryStats) override { |
| 21 m_totalActiveBytes += memoryStats->totalActiveBytes; | 21 m_totalActiveBytes += memoryStats->total_active_bytes; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void partitionsDumpBucketStats( | 24 void PartitionsDumpBucketStats( |
| 25 const char* partitionName, | 25 const char* partitionName, |
| 26 const WTF::PartitionBucketMemoryStats*) override {} | 26 const WTF::PartitionBucketMemoryStats*) override {} |
| 27 | 27 |
| 28 size_t totalActiveBytes() const { return m_totalActiveBytes; } | 28 size_t totalActiveBytes() const { return m_totalActiveBytes; } |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 size_t m_totalActiveBytes; | 31 size_t m_totalActiveBytes; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 WebMemoryStatistics WebMemoryStatistics::Get() { | 36 WebMemoryStatistics WebMemoryStatistics::Get() { |
| 37 LightPartitionStatsDumperImpl dumper; | 37 LightPartitionStatsDumperImpl dumper; |
| 38 WebMemoryStatistics statistics; | 38 WebMemoryStatistics statistics; |
| 39 | 39 |
| 40 WTF::Partitions::dumpMemoryStats(true, &dumper); | 40 WTF::Partitions::dumpMemoryStats(true, &dumper); |
| 41 statistics.partitionAllocTotalAllocatedBytes = dumper.totalActiveBytes(); | 41 statistics.partitionAllocTotalAllocatedBytes = dumper.totalActiveBytes(); |
| 42 | 42 |
| 43 statistics.blinkGCTotalAllocatedBytes = | 43 statistics.blinkGCTotalAllocatedBytes = |
| 44 ProcessHeap::totalAllocatedObjectSize() + | 44 ProcessHeap::totalAllocatedObjectSize() + |
| 45 ProcessHeap::totalMarkedObjectSize(); | 45 ProcessHeap::totalMarkedObjectSize(); |
| 46 return statistics; | 46 return statistics; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace blink | 49 } // namespace blink |
| OLD | NEW |