Add some UMAs for offline pages
[chromium-blink-merge.git] / skia / ext / skia_memory_dump_provider.cc
blob3944ad40fa3d48b0589678166b49796d6e93e572
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 "third_party/skia/include/core/SkGraphics.h"
11 #include "third_party/skia/src/core/SkResourceCache.h"
13 namespace skia {
15 // static
16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
17 return Singleton<SkiaMemoryDumpProvider,
18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
25 bool SkiaMemoryDumpProvider::OnMemoryDump(
26 const base::trace_event::MemoryDumpArgs& args,
27 base::trace_event::ProcessMemoryDump* process_memory_dump) {
28 auto font_mad =
29 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache");
30 font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed());
31 font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed());
33 auto resource_mad =
34 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
35 resource_mad->AddScalar("size", "bytes",
36 SkResourceCache::GetTotalBytesUsed());
37 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or
38 // malloc memory dumps to avoid double counting.
40 return true;
43 } // namespace skia