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

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

Issue 1259333003: [tracing] Add SkResourceCache as suballocation to avoid double counting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_v1
Patch Set: Clean up. 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
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 "third_party/skia/include/core/SkGraphics.h" 10 #include "third_party/skia/include/core/SkGraphics.h"
11 #include "third_party/skia/src/core/SkResourceCache.h" 11 #include "third_party/skia/src/core/SkResourceCache.h"
12 12
13 namespace skia { 13 namespace skia {
14 14
15 // static 15 // static
16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() { 16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
17 return Singleton<SkiaMemoryDumpProvider, 17 return Singleton<SkiaMemoryDumpProvider,
18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get(); 18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
19 } 19 }
20 20
21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {} 21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
22 22
23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {} 23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
24 24
25 bool SkiaMemoryDumpProvider::OnMemoryDump( 25 bool SkiaMemoryDumpProvider::OnMemoryDump(
26 base::trace_event::ProcessMemoryDump* process_memory_dump) { 26 base::trace_event::ProcessMemoryDump* process_memory_dump) {
27 auto font_mad = 27 auto font_mad =
28 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache"); 28 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache");
29 font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed()); 29 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
30 font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed()); 30 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
31 SkGraphics::GetFontCacheUsed());
32 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
33 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
34 SkGraphics::GetFontCacheCountUsed());
31 35
32 auto resource_mad = 36 size_t skia_resource_cache_size = SkResourceCache::GetTotalBytesUsed();
33 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache"); 37 if (skia_resource_cache_size > 0) {
petrcermak 2015/07/29 11:53:34 Shouldn't we report zero explicitly as well?
ssid 2015/07/29 16:20:51 Yea i think it makes more sense to dump 0
34 resource_mad->AddScalar("size", "bytes", 38 auto resource_mad =
35 SkResourceCache::GetTotalBytesUsed()); 39 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
36 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or 40 resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
37 // malloc memory dumps to avoid double counting. 41 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
38 42 skia_resource_cache_size);
43 if (SkResourceCache::GetDiscardableFactory()) {
44 process_memory_dump->AddSuballocation(resource_mad->guid(),
petrcermak 2015/07/29 11:53:34 You could use a ternary operator or factor out the
45 "discardable/allocated_objects");
46 } else {
47 process_memory_dump->AddSuballocation(resource_mad->guid(),
48 "malloc/allocated_objects");
petrcermak 2015/07/29 11:53:34 Please use the base::trace_event::MallocDumpProvid
ssid 2015/07/29 16:20:51 Done.
49 }
50 }
39 return true; 51 return true;
40 } 52 }
41 53
42 } // namespace skia 54 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698