summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 21:11:04 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 21:11:04 +0000
commitfc6321e66b6bd411dc593f5a1a356c25b49597e8 (patch)
treee341f7ab84ecf53ce8f866b794156c4a3de556b8 /webkit
parenteb3cac713b9d8d6f1f12f55df9e05c56ba64af41 (diff)
downloadchromium_src-fc6321e66b6bd411dc593f5a1a356c25b49597e8.zip
chromium_src-fc6321e66b6bd411dc593f5a1a356c25b49597e8.tar.gz
chromium_src-fc6321e66b6bd411dc593f5a1a356c25b49597e8.tar.bz2
Estimate the renderer working set on Linux. This is less expensive and works in the Chromium SUID sandbox because it does not require access to /proc.
BUG=32519 TEST=none Review URL: http://codereview.chromium.org/593060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkitclient_impl.cc56
1 files changed, 51 insertions, 5 deletions
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index 322ca09..53da614 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -4,8 +4,14 @@
#include "webkit/glue/webkitclient_impl.h"
+#if defined(OS_LINUX)
+#include <malloc.h>
+#endif
+
#include <math.h>
+#include <vector>
+
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -31,6 +37,10 @@
#include "webkit/glue/websocketstreamhandle_impl.h"
#include "webkit/glue/weburlloader_impl.h"
+#if defined(OS_LINUX)
+#include "v8/include/v8.h"
+#endif
+
using WebKit::WebApplicationCacheHost;
using WebKit::WebApplicationCacheHostClient;
using WebKit::WebCookie;
@@ -143,7 +153,7 @@ void WebKitClientImpl::getPluginList(bool refresh,
WideToUTF16Hack(plugin.desc),
FilePathStringToWebString(plugin.path.BaseName().value()));
- for (size_t j = 0; j < plugin.mime_types.size(); ++ j) {
+ for (size_t j = 0; j < plugin.mime_types.size(); ++j) {
const WebPluginMimeType& mime_type = plugin.mime_types[j];
builder->addMediaTypeToLastPlugin(
@@ -309,20 +319,56 @@ WebKit::WebString WebKitClientImpl::signedPublicKeyAndChallengeString(
return WebKit::WebString();
}
-size_t WebKitClientImpl::memoryUsageMB() {
+#if defined(OS_LINUX)
+static size_t memoryUsageMBLinux() {
+ struct mallinfo minfo = mallinfo();
+ uint64_t mem_usage =
+#if defined(USE_TCMALLOC)
+ minfo.uordblks
+#else
+ (minfo.hblkhd + minfo.arena)
+#endif
+ >> 20;
+
+ v8::HeapStatistics stat;
+ v8::V8::GetHeapStatistics(&stat);
+ mem_usage += static_cast<uint64_t>(stat.total_heap_size()) >> 20;
+ return mem_usage;
+}
+#endif
+
+#if defined(OS_MACOSX)
+static size_t memoryUsageMBMac() {
using base::ProcessMetrics;
static ProcessMetrics* process_metrics =
-#if !defined(OS_MACOSX)
- ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle());
-#else
// The default port provider is sufficient to get data for the current
// process.
ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
NULL);
+ DCHECK(process_metrics);
+ return process_metrics->GetPagefileUsage() >> 20;
+}
#endif
+
+#if !defined(OS_LINUX) && !defined(OS_MACOSX)
+static size_t memoryUsageMBGeneric() {
+ using base::ProcessMetrics;
+ static ProcessMetrics* process_metrics =
+ ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle());
DCHECK(process_metrics);
return process_metrics->GetPagefileUsage() >> 20;
}
+#endif
+
+size_t WebKitClientImpl::memoryUsageMB() {
+#if defined(OS_LINUX)
+ return memoryUsageMBLinux();
+#elif defined(OS_MACOSX)
+ return memoryUsageMBMac();
+#else
+ return memoryUsageMBGeneric();
+#endif
+}
bool WebKitClientImpl::fileExists(const WebKit::WebString& path) {
FilePath::StringType file_path = webkit_glue::WebStringToFilePathString(path);