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

Unified Diff: third_party/WebKit/Source/web/WebMemoryStatistics.cpp

Issue 2350423003: [Tentaive patch for discussion] Add Purge+Suspend metrics as UMA.
Patch Set: Fixed misuse of CanPurgeAndSuspend Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d5d262b2198a40dbdd27e9ebdea8f4b8b7c01fd
--- /dev/null
+++ b/third_party/WebKit/Source/web/WebMemoryStatistics.cpp
@@ -0,0 +1,53 @@
+// 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)
+ , m_totalResidentBytes(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; }
+ size_t totalResidentBytes() const { return m_totalResidentBytes; }
+
+ private:
+ size_t m_totalActiveBytes;
+ size_t m_totalResidentBytes;
+ };
+
+ void LightPartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, const WTF::PartitionMemoryStats* memoryStats)
+ {
+ m_totalActiveBytes += memoryStats->totalActiveBytes;
+ m_totalResidentBytes += memoryStats->totalResidentBytes;
+ }
+}
+
+WebMemoryStatistics WebMemoryStatistics::Get()
+{
+ LightPartitionStatsDumperImpl dumper;
+ WebMemoryStatistics statistics;
+
+ WTF::Partitions::dumpMemoryStats(true, &dumper);
+ statistics.partitionAllocTotalAllocatedBytes = dumper.totalActiveBytes();
+ statistics.partitionAllocTotalBytes = dumper.totalResidentBytes();
+
+ statistics.blinkGCTotalBytes = ProcessHeap::totalAllocatedSpace();
+ statistics.blinkGCTotalAllocatedBytes = ProcessHeap::totalAllocatedObjectSize() + ProcessHeap::totalMarkedObjectSize();
+ return statistics;
+}
+}
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698