Index: skia/ext/SkTraceMemoryDump_chrome.cc |
diff --git a/skia/ext/SkTraceMemoryDump_chrome.cc b/skia/ext/SkTraceMemoryDump_chrome.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c91c8e21878b15117f72d4d72cd62dfc9c0063c7 |
--- /dev/null |
+++ b/skia/ext/SkTraceMemoryDump_chrome.cc |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "skia/ext/SkTraceMemoryDump_chrome.h" |
+ |
+#include "base/trace_event/memory_allocator_dump.h" |
+#include "base/trace_event/memory_dump_manager.h" |
+#include "base/trace_event/process_memory_dump.h" |
+#include "skia/ext/SkDiscardableMemory_chrome.h" |
+ |
+namespace skia { |
+ |
+SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome( |
+ base::trace_event::ProcessMemoryDump* process_memory_dump) |
+ : process_memory_dump_(process_memory_dump) {} |
+ |
+SkTraceMemoryDump_Chrome::~SkTraceMemoryDump_Chrome() {} |
+ |
+void SkTraceMemoryDump_Chrome::dumpNumericValue(const char* dumpName, |
+ const char* valueName, |
+ const char* units, |
+ uint64_t value) { |
+ auto mad = process_memory_dump_->GetAllocatorDump(dumpName); |
+ if (!mad) |
+ mad = process_memory_dump_->CreateAllocatorDump(dumpName); |
+ mad->AddScalar(valueName, units, value); |
+} |
+ |
+void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName, |
+ const char* backingType, |
+ const char* backingObjectId) { |
+ if (strcmp(backingType, "malloc") == 0) { |
+ 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
|
+ process_memory_dump_->AddSuballocation( |
+ mad->guid(), base::trace_event::MemoryDumpManager::GetInstance() |
+ ->system_allocator_pool_name()); |
+ } |
+} |
+ |
+void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking( |
+ const char* dumpName, |
+ const SkDiscardableMemory& discardableMemoryObject) { |
+ const SkDiscardableMemoryChrome& memory = |
+ 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.
|
+ discardableMemoryObject); |
+ 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.
|
+ DCHECK(mad); |
+} |
+ |
+} // namespace skia |