Roll WebRTC 9846:9854, Libjingle 9845:9853
[chromium-blink-merge.git] / skia / ext / skia_memory_dump_provider.cc
blob1323699ddb1ef54febcb4aadfc8fc16754d77949
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.
5 #include "skia_memory_dump_provider.h"
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 "skia/ext/SkTraceMemoryDump_chrome.h"
11 #include "third_party/skia/include/core/SkGraphics.h"
12 #include "third_party/skia/src/core/SkResourceCache.h"
14 namespace skia {
16 // static
17 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
18 return Singleton<SkiaMemoryDumpProvider,
19 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
22 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
24 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
26 bool SkiaMemoryDumpProvider::OnMemoryDump(
27 const base::trace_event::MemoryDumpArgs& args,
28 base::trace_event::ProcessMemoryDump* process_memory_dump) {
29 base::trace_event::MemoryAllocatorDump* font_mad =
30 process_memory_dump->CreateAllocatorDump("skia/sk_glyph_cache");
31 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
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());
38 if (args.level_of_detail ==
39 base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
40 return true;
42 SkTraceMemoryDump_Chrome skia_dumper(process_memory_dump);
43 SkGraphics::DumpMemoryStatistics(&skia_dumper);
45 return true;
48 } // namespace skia