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

Unified Diff: third_party/WebKit/Source/platform/MemoryUsageProvider.cpp

Issue 1670463002: [Oilpan] Unify memory usage reporters of Oilpan (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Watch out only Oilpan heap usages Created 4 years, 10 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
Index: third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
diff --git a/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp b/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1defd66978887744956bc54d0944d6020005dc6
--- /dev/null
+++ b/third_party/WebKit/Source/platform/MemoryUsageProvider.cpp
@@ -0,0 +1,48 @@
+// 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 "platform/MemoryUsageProvider.h"
+
+#include "platform/heap/Heap.h"
+#include "public/platform/WebMemoryAllocatorDump.h"
+#include "public/platform/WebProcessMemoryDump.h"
+#include "wtf/Partitions.h"
+#include "wtf/Threading.h"
+#include "wtf/text/WTFString.h"
+
+#include <v8.h>
+
+namespace blink {
+
+MemoryUsageProvider* MemoryUsageProvider::instance()
+{
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<MemoryUsageProvider>, provider, new ThreadSpecific<MemoryUsageProvider>);
+ return provider;
+}
+
+MemoryUsageProvider::MemoryUsageProvider()
+ : m_isolate(nullptr)
+ , m_previousSize(0)
+{
+}
+
+MemoryUsageProvider::~MemoryUsageProvider()
+{
+}
+
+bool MemoryUsageProvider::adjustAmountOfAllocatedMemory()
+{
+ if (!m_isolate)
+ return false;
+
+ // TODO(peria): Use thread specific heap usage methods, if available.
+ int64_t currentTotalSize = Heap::allocatedObjectSize() + Heap::markedObjectSize();
haraken 2016/02/08 11:17:20 This is not what we want to report. Heap::allocate
peria 2016/02/09 06:39:59 Done.
+ int64_t diff = currentTotalSize - m_previousSize;
+ m_isolate->AdjustAmountOfExternalAllocatedMemory(diff);
+ m_previousSize = currentTotalSize;
+
+ return true;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698