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

Side by Side Diff: skia/ext/skia_memory_dump_provider.cc

Issue 1319473003: [tracing] Add SkResourceCache statistics to chrome://tracing (chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@discardable_objdumps
Patch Set: Mac build fix. 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 unified diff | Download patch
« no previous file with comments | « skia/ext/SkTraceMemoryDump_chrome.cc ('k') | skia/ext/skia_memory_dump_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia_memory_dump_provider.h" 5 #include "skia_memory_dump_provider.h"
6 6
7 #include "base/trace_event/memory_allocator_dump.h" 7 #include "base/trace_event/memory_allocator_dump.h"
8 #include "base/trace_event/memory_dump_manager.h" 8 #include "base/trace_event/memory_dump_manager.h"
9 #include "base/trace_event/process_memory_dump.h" 9 #include "base/trace_event/process_memory_dump.h"
10 #include "skia/ext/SkTraceMemoryDump_chrome.h"
10 #include "third_party/skia/include/core/SkGraphics.h" 11 #include "third_party/skia/include/core/SkGraphics.h"
11 #include "third_party/skia/src/core/SkResourceCache.h" 12 #include "third_party/skia/src/core/SkResourceCache.h"
12 13
13 namespace skia { 14 namespace skia {
14 15
15 // static 16 // static
16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() { 17 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
17 return Singleton<SkiaMemoryDumpProvider, 18 return Singleton<SkiaMemoryDumpProvider,
18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get(); 19 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
19 } 20 }
20 21
21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {} 22 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
22 23
23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {} 24 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
24 25
25 bool SkiaMemoryDumpProvider::OnMemoryDump( 26 bool SkiaMemoryDumpProvider::OnMemoryDump(
26 const base::trace_event::MemoryDumpArgs& args, 27 const base::trace_event::MemoryDumpArgs& args,
27 base::trace_event::ProcessMemoryDump* process_memory_dump) { 28 base::trace_event::ProcessMemoryDump* process_memory_dump) {
28 auto font_mad = 29 base::trace_event::MemoryAllocatorDump* font_mad =
29 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache"); 30 process_memory_dump->CreateAllocatorDump("skia/sk_glyph_cache");
30 font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed()); 31 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
31 font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed()); 32 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
33 SkGraphics::GetFontCacheUsed());
34 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
35 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
36 SkGraphics::GetFontCacheCountUsed());
32 37
33 auto resource_mad = 38 if (args.level_of_detail ==
34 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache"); 39 base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
35 resource_mad->AddScalar("size", "bytes", 40 return true;
36 SkResourceCache::GetTotalBytesUsed()); 41
37 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or 42 SkTraceMemoryDump_Chrome skia_dumper(process_memory_dump);
38 // malloc memory dumps to avoid double counting. 43 SkGraphics::DumpMemoryStatistics(&skia_dumper);
39 44
40 return true; 45 return true;
41 } 46 }
42 47
43 } // namespace skia 48 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/SkTraceMemoryDump_chrome.cc ('k') | skia/ext/skia_memory_dump_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698