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

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

Issue 1327793003: Move WebCache memory dump provider to blink for sub-allocation edges. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moving branch. Created 5 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
Index: third_party/WebKit/Source/web/WebCacheMemoryDumpProvider.cpp
diff --git a/third_party/WebKit/Source/web/WebCacheMemoryDumpProvider.cpp b/third_party/WebKit/Source/web/WebCacheMemoryDumpProvider.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9dee7552b1b553f57802e29c03fb5a33ac00b8a7
--- /dev/null
+++ b/third_party/WebKit/Source/web/WebCacheMemoryDumpProvider.cpp
@@ -0,0 +1,97 @@
+// Copyright 2015 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 "config.h"
+#include "web/WebCacheMemoryDumpProvider.h"
+
+#include "public/platform/Platform.h"
+#include "public/platform/WebMemoryAllocatorDump.h"
+#include "public/platform/WebProcessMemoryDump.h"
+#include "public/web/WebCache.h"
+#include "wtf/MainThread.h"
+#include <inttypes.h>
+
+namespace blink {
+
+namespace {
+
+using namespace WTF;
+
+WebCacheMemoryDumpProvider* gWebCacheMemoryDumpProvider;
+
+// TODO(ssid): Expose the AddSuballocation method to WebMemoryDumpProvider.
+void AddSuballocation(WebProcessMemoryDump* memoryDump, const WebMemoryAllocatorDumpGuid& sourceGuid, const char* target)
+{
+ String dumpName = String::format("%s/__%" PRIX64, target, sourceGuid);
+ WebMemoryAllocatorDump* targetChildDump = memoryDump->createMemoryAllocatorDump(dumpName);
+ memoryDump->AddOwnershipEdge(sourceGuid, targetChildDump->guid());
+}
+
+void DumpResourceStats(const WebCache::ResourceTypeStat& resourceStat, const String& resourceName, WebProcessMemoryDump* memoryDump)
+{
+ WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDump(resourceName);
+ allocatorDump->AddScalar("count", "objects", resourceStat.count);
+ allocatorDump->AddScalar("live_size", "bytes", resourceStat.liveSize);
+ allocatorDump->AddScalar("purged_size", "bytes", resourceStat.purgedSize);
+ allocatorDump->AddScalar("purgeable_size", "bytes", resourceStat.purgeableSize);
+
+ const String objectsName = resourceName + "/raw_objects";
+ WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(objectsName);
+ objectsDump->AddScalar("size", "bytes", resourceStat.size - resourceStat.decodedSize);
+
+ AddSuballocation(memoryDump, objectsDump->guid(), Partitions::allocatorPoolNameForTracing());
+
+ // Decoded images are dumped by skia cache, which takes ownership of the resources.
+ if (!resourceName.contains("images") && resourceStat.decodedSize > 0) {
+ const String decodedName = resourceName + "/decoded";
+ WebMemoryAllocatorDump* decodedDump = memoryDump->createMemoryAllocatorDump(decodedName);
+ decodedDump->AddScalar("size", "bytes", resourceStat.decodedSize);
+
+ AddSuballocation(memoryDump, decodedDump->guid(), Partitions::allocatorPoolNameForTracing());
+ }
+}
+
+} // namespace
+
+void WebCacheMemoryDumpProvider::initialize()
+{
+ ASSERT(isMainThread());
+ if (!gWebCacheMemoryDumpProvider)
+ gWebCacheMemoryDumpProvider = new WebCacheMemoryDumpProvider();
+}
+
+bool WebCacheMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump)
+{
+ WebCache::UsageStats memoryStats;
+ WebCache::getUsageStats(&memoryStats);
+
+ String dumpName("web_cache");
+ WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDump(dumpName);
+
+ allocatorDump->AddScalar("live_size", "bytes", memoryStats.liveSize);
+ allocatorDump->AddScalar("dead_size", "bytes", memoryStats.deadSize);
+
+ WebCache::ResourceTypeStats resourceStats;
+ WebCache::getResourceTypeStats(&resourceStats);
+ DumpResourceStats(resourceStats.images, dumpName + "/images", memoryDump);
+ DumpResourceStats(resourceStats.cssStyleSheets, dumpName + "/css_style_sheets", memoryDump);
+ DumpResourceStats(resourceStats.scripts, dumpName + "/scripts", memoryDump);
+ DumpResourceStats(resourceStats.xslStyleSheets, dumpName + "/xsl_style_sheets", memoryDump);
+ DumpResourceStats(resourceStats.fonts, dumpName + "/fonts", memoryDump);
+ DumpResourceStats(resourceStats.other, dumpName + "/other", memoryDump);
+
+ return true;
+}
+
+WebCacheMemoryDumpProvider::WebCacheMemoryDumpProvider()
+{
+ Platform::current()->registerMemoryDumpProvider(this);
+}
+
+WebCacheMemoryDumpProvider::~WebCacheMemoryDumpProvider()
+{
+ Platform::current()->unregisterMemoryDumpProvider(this);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/WebCacheMemoryDumpProvider.h ('k') | third_party/WebKit/Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698