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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "web/WebCacheMemoryDumpProvider.h"
7
8 #include "public/platform/Platform.h"
9 #include "public/platform/WebMemoryAllocatorDump.h"
10 #include "public/platform/WebProcessMemoryDump.h"
11 #include "public/web/WebCache.h"
12 #include "wtf/MainThread.h"
13 #include <inttypes.h>
14
15 namespace blink {
16
17 namespace {
18
19 using namespace WTF;
20
21 WebCacheMemoryDumpProvider* gWebCacheMemoryDumpProvider;
22
23 // TODO(ssid): Expose the AddSuballocation method to WebMemoryDumpProvider.
24 void AddSuballocation(WebProcessMemoryDump* memoryDump, const WebMemoryAllocator DumpGuid& sourceGuid, const char* target)
25 {
26 String dumpName = String::format("%s/__%" PRIX64, target, sourceGuid);
27 WebMemoryAllocatorDump* targetChildDump = memoryDump->createMemoryAllocatorD ump(dumpName);
28 memoryDump->AddOwnershipEdge(sourceGuid, targetChildDump->guid());
29 }
30
31 void DumpResourceStats(const WebCache::ResourceTypeStat& resourceStat, const Str ing& resourceName, WebProcessMemoryDump* memoryDump)
32 {
33 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p(resourceName);
34 allocatorDump->AddScalar("count", "objects", resourceStat.count);
35 allocatorDump->AddScalar("live_size", "bytes", resourceStat.liveSize);
36 allocatorDump->AddScalar("purged_size", "bytes", resourceStat.purgedSize);
37 allocatorDump->AddScalar("purgeable_size", "bytes", resourceStat.purgeableSi ze);
38
39 const String objectsName = resourceName + "/raw_objects";
40 WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump( objectsName);
41 objectsDump->AddScalar("size", "bytes", resourceStat.size - resourceStat.dec odedSize);
42
43 AddSuballocation(memoryDump, objectsDump->guid(), Partitions::allocatorPoolN ameForTracing());
44
45 // Decoded images are dumped by skia cache, which takes ownership of the res ources.
46 if (!resourceName.contains("images") && resourceStat.decodedSize > 0) {
47 const String decodedName = resourceName + "/decoded";
48 WebMemoryAllocatorDump* decodedDump = memoryDump->createMemoryAllocatorD ump(decodedName);
49 decodedDump->AddScalar("size", "bytes", resourceStat.decodedSize);
50
51 AddSuballocation(memoryDump, decodedDump->guid(), Partitions::allocatorP oolNameForTracing());
52 }
53 }
54
55 } // namespace
56
57 void WebCacheMemoryDumpProvider::initialize()
58 {
59 ASSERT(isMainThread());
60 if (!gWebCacheMemoryDumpProvider)
61 gWebCacheMemoryDumpProvider = new WebCacheMemoryDumpProvider();
62 }
63
64 bool WebCacheMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOf Detail, WebProcessMemoryDump* memoryDump)
65 {
66 WebCache::UsageStats memoryStats;
67 WebCache::getUsageStats(&memoryStats);
68
69 String dumpName("web_cache");
70 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p(dumpName);
71
72 allocatorDump->AddScalar("live_size", "bytes", memoryStats.liveSize);
73 allocatorDump->AddScalar("dead_size", "bytes", memoryStats.deadSize);
74
75 WebCache::ResourceTypeStats resourceStats;
76 WebCache::getResourceTypeStats(&resourceStats);
77 DumpResourceStats(resourceStats.images, dumpName + "/images", memoryDump);
78 DumpResourceStats(resourceStats.cssStyleSheets, dumpName + "/css_style_sheet s", memoryDump);
79 DumpResourceStats(resourceStats.scripts, dumpName + "/scripts", memoryDump);
80 DumpResourceStats(resourceStats.xslStyleSheets, dumpName + "/xsl_style_sheet s", memoryDump);
81 DumpResourceStats(resourceStats.fonts, dumpName + "/fonts", memoryDump);
82 DumpResourceStats(resourceStats.other, dumpName + "/other", memoryDump);
83
84 return true;
85 }
86
87 WebCacheMemoryDumpProvider::WebCacheMemoryDumpProvider()
88 {
89 Platform::current()->registerMemoryDumpProvider(this);
90 }
91
92 WebCacheMemoryDumpProvider::~WebCacheMemoryDumpProvider()
93 {
94 Platform::current()->unregisterMemoryDumpProvider(this);
95 }
96
97 } // namespace blink
OLDNEW
« 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