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

Unified Diff: webkit/child/webkit_child_helpers.cc

Issue 20003004: reland crrev.com/212927 Move webkitplatformsupport_impl and related from glue to child (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & allocator dep for components_unittests in shared_library2 Created 7 years, 5 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 | « webkit/child/webkit_child_helpers.h ('k') | webkit/child/webkitplatformsupport_child_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/child/webkit_child_helpers.cc
diff --git a/webkit/child/webkit_child_helpers.cc b/webkit/child/webkit_child_helpers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..67779550dde64c32cac1e18b8fb06d929d34eed1
--- /dev/null
+++ b/webkit/child/webkit_child_helpers.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 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 "webkit/child/webkit_child_helpers.h"
+
+#if defined(OS_LINUX)
+#include <malloc.h>
+#endif
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/process_util.h"
+#include "v8/include/v8.h"
+
+namespace webkit_glue {
+
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+size_t MemoryUsageKB() {
+ struct mallinfo minfo = mallinfo();
+ uint64_t mem_usage =
+#if defined(USE_TCMALLOC)
+ minfo.uordblks
+#else
+ (minfo.hblkhd + minfo.arena)
+#endif
+ >> 10;
+
+ v8::HeapStatistics stat;
+ // TODO(svenpanne) The call below doesn't take web workers into account, this
+ // has to be done manually by iterating over all Isolates involved.
+ v8::Isolate::GetCurrent()->GetHeapStatistics(&stat);
+ return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10);
+}
+#elif defined(OS_MACOSX)
+size_t MemoryUsageKB() {
+ scoped_ptr<base::ProcessMetrics> process_metrics(
+ // The default port provider is sufficient to get data for the current
+ // process.
+ base::ProcessMetrics::CreateProcessMetrics(
+ base::GetCurrentProcessHandle(), NULL));
+ return process_metrics->GetWorkingSetSize() >> 10;
+}
+#else
+size_t MemoryUsageKB() {
+ scoped_ptr<base::ProcessMetrics> process_metrics(
+ base::ProcessMetrics::CreateProcessMetrics(
+ base::GetCurrentProcessHandle()));
+ return process_metrics->GetPagefileUsage() >> 10;
+}
+#endif
+
+} // webkit_glue
« no previous file with comments | « webkit/child/webkit_child_helpers.h ('k') | webkit/child/webkitplatformsupport_child_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698