| 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..7b55f5bd3affea40c567cf0726b2573ceb9488a9
|
| --- /dev/null
|
| +++ b/skia/ext/SkTraceMemoryDump_chrome.cc
|
| @@ -0,0 +1,63 @@
|
| +// 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/strings/string_util.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 {
|
| +
|
| +namespace {
|
| +const char kMallocBackingType[] = "malloc";
|
| +}
|
| +
|
| +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 dump = GetOrCreateAllocatorDump(dumpName);
|
| + dump->AddScalar(valueName, units, value);
|
| +}
|
| +
|
| +void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName,
|
| + const char* backingType,
|
| + const char* backingObjectId) {
|
| + if (base::CompareCaseInsensitiveASCII(backingType, kMallocBackingType) == 0) {
|
| + auto dump = GetOrCreateAllocatorDump(dumpName);
|
| + process_memory_dump_->AddSuballocation(
|
| + dump->guid(), base::trace_event::MemoryDumpManager::GetInstance()
|
| + ->system_allocator_pool_name());
|
| + }
|
| +}
|
| +
|
| +void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking(
|
| + const char* dumpName,
|
| + const SkDiscardableMemory& discardableMemoryObject) {
|
| + DCHECK(!process_memory_dump_->GetAllocatorDump(dumpName));
|
| + const SkDiscardableMemoryChrome& discardable_memory_obj =
|
| + static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject);
|
| + auto dump = discardable_memory_obj.CreateMemoryAllocatorDump(
|
| + dumpName, process_memory_dump_);
|
| + DCHECK(dump);
|
| +}
|
| +
|
| +base::trace_event::MemoryAllocatorDump*
|
| +SkTraceMemoryDump_Chrome::GetOrCreateAllocatorDump(const char* dumpName) {
|
| + auto dump = process_memory_dump_->GetAllocatorDump(dumpName);
|
| + if (!dump)
|
| + dump = process_memory_dump_->CreateAllocatorDump(dumpName);
|
| + return dump;
|
| +}
|
| +
|
| +} // namespace skia
|
|
|