| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT | 30 level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT |
| 31 ? SkTraceMemoryDump::kLight_LevelOfDetail | 31 ? SkTraceMemoryDump::kLight_LevelOfDetail |
| 32 : SkTraceMemoryDump::kObjectsBreakdowns_LevelOfDetail) {} | 32 : SkTraceMemoryDump::kObjectsBreakdowns_LevelOfDetail) {} |
| 33 | 33 |
| 34 SkiaTraceMemoryDumpImpl::~SkiaTraceMemoryDumpImpl() {} | 34 SkiaTraceMemoryDumpImpl::~SkiaTraceMemoryDumpImpl() {} |
| 35 | 35 |
| 36 void SkiaTraceMemoryDumpImpl::dumpNumericValue(const char* dumpName, | 36 void SkiaTraceMemoryDumpImpl::dumpNumericValue(const char* dumpName, |
| 37 const char* valueName, | 37 const char* valueName, |
| 38 const char* units, | 38 const char* units, |
| 39 uint64_t value) { | 39 uint64_t value) { |
| 40 auto dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); | 40 auto* dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); |
| 41 dump->AddScalar(valueName, units, value); | 41 dump->AddScalar(valueName, units, value); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SkiaTraceMemoryDumpImpl::setMemoryBacking(const char* dumpName, | 44 void SkiaTraceMemoryDumpImpl::setMemoryBacking(const char* dumpName, |
| 45 const char* backingType, | 45 const char* backingType, |
| 46 const char* backingObjectId) { | 46 const char* backingObjectId) { |
| 47 if (strcmp(backingType, kMallocBackingType) == 0) { | 47 if (strcmp(backingType, kMallocBackingType) == 0) { |
| 48 auto dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); | 48 auto* dump = process_memory_dump_->GetOrCreateAllocatorDump(dumpName); |
| 49 const char* system_allocator_name = | 49 const char* system_allocator_name = |
| 50 base::trace_event::MemoryDumpManager::GetInstance() | 50 base::trace_event::MemoryDumpManager::GetInstance() |
| 51 ->system_allocator_pool_name(); | 51 ->system_allocator_pool_name(); |
| 52 if (system_allocator_name) { | 52 if (system_allocator_name) { |
| 53 process_memory_dump_->AddSuballocation(dump->guid(), | 53 process_memory_dump_->AddSuballocation(dump->guid(), |
| 54 system_allocator_name); | 54 system_allocator_name); |
| 55 } | 55 } |
| 56 } else { | 56 } else { |
| 57 NOTREACHED(); | 57 NOTREACHED(); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SkiaTraceMemoryDumpImpl::setDiscardableMemoryBacking( | 61 void SkiaTraceMemoryDumpImpl::setDiscardableMemoryBacking( |
| 62 const char* dumpName, | 62 const char* dumpName, |
| 63 const SkDiscardableMemory& discardableMemoryObject) { | 63 const SkDiscardableMemory& discardableMemoryObject) { |
| 64 std::string name = dump_name_prefix_ + dumpName; | 64 std::string name = dump_name_prefix_ + dumpName; |
| 65 DCHECK(!process_memory_dump_->GetAllocatorDump(name)); | 65 DCHECK(!process_memory_dump_->GetAllocatorDump(name)); |
| 66 const SkDiscardableMemoryChrome& discardable_memory_obj = | 66 const SkDiscardableMemoryChrome& discardable_memory_obj = |
| 67 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); | 67 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); |
| 68 auto dump = discardable_memory_obj.CreateMemoryAllocatorDump( | 68 auto* dump = discardable_memory_obj.CreateMemoryAllocatorDump( |
| 69 name.c_str(), process_memory_dump_); | 69 name.c_str(), process_memory_dump_); |
| 70 DCHECK(dump); | 70 DCHECK(dump); |
| 71 } | 71 } |
| 72 | 72 |
| 73 SkTraceMemoryDump::LevelOfDetail SkiaTraceMemoryDumpImpl::getRequestedDetails() | 73 SkTraceMemoryDump::LevelOfDetail SkiaTraceMemoryDumpImpl::getRequestedDetails() |
| 74 const { | 74 const { |
| 75 return request_level_; | 75 return request_level_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace skia | 78 } // namespace skia |
| OLD | NEW |