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

Unified Diff: skia/ext/skia_memory_dump_provider.cc

Issue 1253403002: [tracing] Adding Skia memory dump provider with cache totals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: skia/ext/skia_memory_dump_provider.cc
diff --git a/skia/ext/skia_memory_dump_provider.cc b/skia/ext/skia_memory_dump_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17ca721ef61193022c9d9233038e90fa6c4e1cdd
--- /dev/null
+++ b/skia/ext/skia_memory_dump_provider.cc
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "skia_memory_dump_provider.h"
+
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
+#include "third_party/skia/include/core/SkGraphics.h"
+#include "third_party/skia/src/core/SkResourceCache.h"
+
+namespace skia {
+
+// static
+SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
+ return Singleton<SkiaMemoryDumpProvider,
+ LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
+}
+
+SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
+
+SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
+
+bool SkiaMemoryDumpProvider::OnMemoryDump(
+ base::trace_event::ProcessMemoryDump* process_memory_dump) {
+ auto font_mad =
+ process_memory_dump->CreateAllocatorDump("skia/sk_font_cache");
+ font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed());
+ font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed());
+
+ auto resource_mad =
+ process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
+ resource_mad->AddScalar("size", "bytes",
+ SkResourceCache::GetTotalBytesUsed());
+ // TODO(ssid): crbug.com/503168. Add sub-allocation edge from discardable or
petrcermak 2015/07/27 15:45:39 nit: Probably "edgeS" (because you say "dumpS" lat
ssid 2015/07/27 16:21:57 Done.
+ // malloc memory dumps to avoid double counting.
+
+ return true;
+}
+
+} // namespace skia

Powered by Google App Engine
This is Rietveld 408576698