OLD | NEW |
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/ext/skia_trace_memory_dump_impl.h" | 5 #include "skia/ext/skia_trace_memory_dump_impl.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/SkDiscardableMemory_chrome.h" | 10 #include "skia/ext/SkDiscardableMemory_chrome.h" |
11 | 11 |
12 namespace skia { | 12 namespace skia { |
13 | 13 |
14 namespace { | 14 namespace { |
15 const char kMallocBackingType[] = "malloc"; | 15 const char kMallocBackingType[] = "malloc"; |
| 16 const char kSkMallocBackingType[] = "skia/sk_malloc"; |
16 } | 17 } |
17 | 18 |
18 SkiaTraceMemoryDumpImpl::SkiaTraceMemoryDumpImpl( | 19 SkiaTraceMemoryDumpImpl::SkiaTraceMemoryDumpImpl( |
19 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, | 20 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
20 base::trace_event::ProcessMemoryDump* process_memory_dump) | 21 base::trace_event::ProcessMemoryDump* process_memory_dump) |
21 : SkiaTraceMemoryDumpImpl("", level_of_detail, process_memory_dump) {} | 22 : SkiaTraceMemoryDumpImpl("", level_of_detail, process_memory_dump) {} |
22 | 23 |
23 SkiaTraceMemoryDumpImpl::SkiaTraceMemoryDumpImpl( | 24 SkiaTraceMemoryDumpImpl::SkiaTraceMemoryDumpImpl( |
24 const std::string& dump_name_prefix, | 25 const std::string& dump_name_prefix, |
25 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, | 26 base::trace_event::MemoryDumpLevelOfDetail level_of_detail, |
(...skipping 20 matching lines...) Expand all Loading... |
46 const char* backingObjectId) { | 47 const char* backingObjectId) { |
47 if (strcmp(backingType, kMallocBackingType) == 0) { | 48 if (strcmp(backingType, kMallocBackingType) == 0) { |
48 auto dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); | 49 auto dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); |
49 const char* system_allocator_name = | 50 const char* system_allocator_name = |
50 base::trace_event::MemoryDumpManager::GetInstance() | 51 base::trace_event::MemoryDumpManager::GetInstance() |
51 ->system_allocator_pool_name(); | 52 ->system_allocator_pool_name(); |
52 if (system_allocator_name) { | 53 if (system_allocator_name) { |
53 process_memory_dump_->AddSuballocation(dump->guid(), | 54 process_memory_dump_->AddSuballocation(dump->guid(), |
54 system_allocator_name); | 55 system_allocator_name); |
55 } | 56 } |
| 57 } else if (strcmp(backingType, kSkMallocBackingType) == 0) { |
| 58 auto dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); |
| 59 process_memory_dump_->AddSuballocation(dump->guid(), backingType); |
56 } else { | 60 } else { |
57 NOTREACHED(); | 61 NOTREACHED(); |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 void SkiaTraceMemoryDumpImpl::setDiscardableMemoryBacking( | 65 void SkiaTraceMemoryDumpImpl::setDiscardableMemoryBacking( |
62 const char* dumpName, | 66 const char* dumpName, |
63 const SkDiscardableMemory& discardableMemoryObject) { | 67 const SkDiscardableMemory& discardableMemoryObject) { |
64 std::string name = dump_name_prefix_ + dumpName; | 68 std::string name = dump_name_prefix_ + dumpName; |
65 DCHECK(!process_memory_dump_->GetAllocatorDump(name)); | 69 DCHECK(!process_memory_dump_->GetAllocatorDump(name)); |
66 const SkDiscardableMemoryChrome& discardable_memory_obj = | 70 const SkDiscardableMemoryChrome& discardable_memory_obj = |
67 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); | 71 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); |
68 auto dump = discardable_memory_obj.CreateMemoryAllocatorDump( | 72 auto dump = discardable_memory_obj.CreateMemoryAllocatorDump( |
69 name.c_str(), process_memory_dump_); | 73 name.c_str(), process_memory_dump_); |
70 DCHECK(dump); | 74 DCHECK(dump); |
71 } | 75 } |
72 | 76 |
73 SkTraceMemoryDump::LevelOfDetail SkiaTraceMemoryDumpImpl::getRequestedDetails() | 77 SkTraceMemoryDump::LevelOfDetail SkiaTraceMemoryDumpImpl::getRequestedDetails() |
74 const { | 78 const { |
75 return request_level_; | 79 return request_level_; |
76 } | 80 } |
77 | 81 |
78 } // namespace skia | 82 } // namespace skia |
OLD | NEW |