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

Side by Side Diff: components/web_cache/renderer/web_cache_memory_dump_provider.cc

Issue 1283793004: [tracing] Add WebCache memory usage in Blink to chrome://tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove browser side dumps. Created 5 years, 4 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 "components/web_cache/renderer/web_cache_memory_dump_provider.h"
6
7 #include "base/trace_event/memory_allocator_dump.h"
8 #include "base/trace_event/memory_dump_manager.h"
9 #include "base/trace_event/process_memory_dump.h"
10 #include "third_party/WebKit/public/web/WebCache.h"
11
12 namespace web_cache {
13 namespace {
14
15 void DumpResourceStats(blink::WebCache::ResourceTypeStat resource_stat,
Primiano Tucci (use gerrit) 2015/08/13 13:30:21 No need to pass a copy. Add const...&
ssid 2015/08/13 15:25:34 Done.
16 const std::string resource_name,
Primiano Tucci (use gerrit) 2015/08/13 13:30:21 same here
ssid 2015/08/13 15:25:34 Done.
17 base::trace_event::ProcessMemoryDump* pmd) {
18 base::trace_event::MemoryAllocatorDump* allocator_dump =
19 pmd->CreateAllocatorDump(resource_name);
20 allocator_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
21 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
22 resource_stat.size);
23 allocator_dump->AddScalar(
24 base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
25 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
26 resource_stat.count);
27 allocator_dump->AddScalar("live_size",
28 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
29 resource_stat.liveSize);
30 allocator_dump->AddScalar("decoded_size",
31 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
32 resource_stat.decodedSize);
33 allocator_dump->AddScalar("purged_size",
34 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
35 resource_stat.purgedSize);
36 allocator_dump->AddScalar("purgeable_size",
37 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
38 resource_stat.purgeableSize);
39 }
40
41 } // namespace
42
43 // static
44 WebCacheMemoryDumpProvider* WebCacheMemoryDumpProvider::GetInstance() {
45 return Singleton<WebCacheMemoryDumpProvider,
46 LeakySingletonTraits<WebCacheMemoryDumpProvider>>::get();
47 }
48
49 WebCacheMemoryDumpProvider::WebCacheMemoryDumpProvider() {}
50
51 WebCacheMemoryDumpProvider::~WebCacheMemoryDumpProvider() {}
52
53 bool WebCacheMemoryDumpProvider::OnMemoryDump(
54 const base::trace_event::MemoryDumpArgs& args,
55 base::trace_event::ProcessMemoryDump* pmd) {
56 blink::WebCache::UsageStats memory_stats = {0};
57 blink::WebCache::getUsageStats(&memory_stats);
58
59 const std::string dump_name("web_cache");
60 base::trace_event::MemoryAllocatorDump* allocator_dump =
61 pmd->CreateAllocatorDump(dump_name);
62
63 allocator_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
64 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
65 memory_stats.liveSize + memory_stats.deadSize);
66 allocator_dump->AddScalar("live_size",
67 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
68 memory_stats.liveSize);
69 allocator_dump->AddScalar("dead_size",
70 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
71 memory_stats.deadSize);
72
73 blink::WebCache::ResourceTypeStats resource_stats;
Primiano Tucci (use gerrit) 2015/08/13 13:30:21 maybe = {0} also here for consistency?
ssid 2015/08/13 15:25:34 Um, it is struct of structs, so it looks dirty. Th
74 blink::WebCache::getResourceTypeStats(&resource_stats);
75 DumpResourceStats(resource_stats.images, dump_name + "/images", pmd);
76 DumpResourceStats(resource_stats.cssStyleSheets,
77 dump_name + "/css_style_sheets", pmd);
78 DumpResourceStats(resource_stats.scripts, dump_name + "/scripts", pmd);
79 DumpResourceStats(resource_stats.xslStyleSheets,
80 dump_name + "/xsl_style_sheets", pmd);
81 DumpResourceStats(resource_stats.fonts, dump_name + "/fonts", pmd);
82 DumpResourceStats(resource_stats.other, dump_name + "/other", pmd);
83
84 return true;
85 }
86
87 } // namespace web_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698