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_->CreateAllocatorDump(dumpName); | |
ericrk
2015/08/25 20:14:50
Don't we want to find the existing allocator dump,
ssid
2015/08/25 20:43:54
This method will be called only once with a given
ericrk
2015/08/25 20:49:56
Fair enough... it's not really clear from the func
ssid
2015/08/25 21:03:24
Hm, you were right, the comment in the api file sa
| |
35 process_memory_dump_->AddSuballocation( | |
36 mad->guid(), base::trace_event::MemoryDumpManager::GetInstance() | |
37 ->system_allocator_pool_name()); | |
38 } | |
39 } | |
40 | |
41 void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking( | |
42 const char* dumpName, | |
43 const SkDiscardableMemory& discardableMemoryObject) { | |
44 const SkDiscardableMemoryChrome& memory = | |
45 reinterpret_cast<const SkDiscardableMemoryChrome&>( | |
ericrk
2015/08/25 20:14:50
shouldn't we static_cast here?
nit: can we add a
ssid
2015/08/25 20:43:54
Yes, it should be static_cast.
| |
46 discardableMemoryObject); | |
47 auto mad = memory.CreateMemoryAllocatorDump(dumpName, process_memory_dump_); | |
ericrk
2015/08/25 20:14:49
same as above, should this try to find an existing
ssid
2015/08/25 20:43:54
hm, the issue is, this goes all the way into imple
ericrk
2015/08/25 20:49:56
See my comment above... I'm OK with a DCHECK.
| |
48 DCHECK(mad); | |
49 } | |
50 | |
51 } // namespace skia | |
OLD | NEW |