| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "public/web/WebMemoryStatistics.h" | |
| 6 | |
| 7 #include "platform/heap/Handle.h" | |
| 8 #include "platform/wtf/allocator/Partitions.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 class LightPartitionStatsDumperImpl : public WTF::PartitionStatsDumper { | |
| 15 public: | |
| 16 LightPartitionStatsDumperImpl() : total_active_bytes_(0) {} | |
| 17 | |
| 18 void PartitionDumpTotals( | |
| 19 const char* partition_name, | |
| 20 const WTF::PartitionMemoryStats* memory_stats) override { | |
| 21 total_active_bytes_ += memory_stats->total_active_bytes; | |
| 22 } | |
| 23 | |
| 24 void PartitionsDumpBucketStats( | |
| 25 const char* partition_name, | |
| 26 const WTF::PartitionBucketMemoryStats*) override {} | |
| 27 | |
| 28 size_t TotalActiveBytes() const { return total_active_bytes_; } | |
| 29 | |
| 30 private: | |
| 31 size_t total_active_bytes_; | |
| 32 }; | |
| 33 | |
| 34 } // namespace | |
| 35 | |
| 36 WebMemoryStatistics WebMemoryStatistics::Get() { | |
| 37 LightPartitionStatsDumperImpl dumper; | |
| 38 WebMemoryStatistics statistics; | |
| 39 | |
| 40 WTF::Partitions::DumpMemoryStats(true, &dumper); | |
| 41 statistics.partition_alloc_total_allocated_bytes = dumper.TotalActiveBytes(); | |
| 42 | |
| 43 statistics.blink_gc_total_allocated_bytes = | |
| 44 ProcessHeap::TotalAllocatedObjectSize() + | |
| 45 ProcessHeap::TotalMarkedObjectSize(); | |
| 46 return statistics; | |
| 47 } | |
| 48 | |
| 49 } // namespace blink | |
| OLD | NEW |