Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "skia/ext/SkTraceMemoryDump_chrome.h" | |
| 6 | |
| 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 "skia/ext/SkDiscardableMemory_chrome.h" | |
| 11 | |
| 12 namespace skia { | |
| 13 | |
| 14 SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome( | |
| 15 base::trace_event::ProcessMemoryDump* process_memory_dump) | |
| 16 : process_memory_dump_(process_memory_dump) {} | |
| 17 | |
| 18 SkTraceMemoryDump_Chrome::~SkTraceMemoryDump_Chrome() {} | |
| 19 | |
| 20 void SkTraceMemoryDump_Chrome::dumpNumericValue(const char* dumpName, | |
| 21 const char* valueName, | |
| 22 const char* units, | |
| 23 uint64_t value) { | |
| 24 auto mad = process_memory_dump_->GetAllocatorDump(dumpName); | |
| 25 if (!mad) | |
| 26 mad = process_memory_dump_->CreateAllocatorDump(dumpName); | |
| 27 mad->AddScalar(valueName, units, value); | |
| 28 } | |
| 29 | |
| 30 void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName, | |
| 31 const char* backingType, | |
| 32 const char* backingObjectId) { | |
| 33 if (strcmp(backingType, "malloc") == 0) { | |
| 34 auto mad = process_memory_dump_->GetAllocatorDump(dumpName); | |
| 35 if (!mad) | |
| 36 mad = process_memory_dump_->CreateAllocatorDump(dumpName); | |
|
Primiano Tucci (use gerrit)
2015/08/26 15:34:01
do you need the GetOrCreate semantic also here? if
ssid
2015/08/26 15:45:19
Ah, sorry. I just updated the CL. after i sent for
| |
| 37 process_memory_dump_->AddSuballocation( | |
| 38 mad->guid(), base::trace_event::MemoryDumpManager::GetInstance() | |
| 39 ->system_allocator_pool_name()); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking( | |
| 44 const char* dumpName, | |
| 45 const SkDiscardableMemory& discardableMemoryObject) { | |
| 46 DCHECK(!process_memory_dump_->GetAllocatorDump(dumpName)); | |
| 47 const SkDiscardableMemoryChrome& memory = | |
|
Primiano Tucci (use gerrit)
2015/08/26 15:34:01
why this dcheck. don't you want the GetOrCreate se
ssid
2015/08/26 15:45:19
Hm, hard failing here because it will fail inside
| |
| 48 static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); | |
| 49 auto mad = memory.CreateMemoryAllocatorDump(dumpName, process_memory_dump_); | |
| 50 DCHECK(mad); | |
|
Primiano Tucci (use gerrit)
2015/08/26 15:34:01
please s/memory/discardable_memory_obj/ or similar
ssid
2015/08/26 15:45:19
Done.
| |
| 51 } | |
| 52 | |
| 53 } // namespace skia | |
| OLD | NEW |