| Index: base/trace_event/memory_allocator_dump.cc
|
| diff --git a/base/trace_event/memory_allocator_dump.cc b/base/trace_event/memory_allocator_dump.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1f89632c2d8ed1317efec91fcc6699d3035cdb4b
|
| --- /dev/null
|
| +++ b/base/trace_event/memory_allocator_dump.cc
|
| @@ -0,0 +1,50 @@
|
| +// 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 "base/trace_event/memory_allocator_dump.h"
|
| +
|
| +#include "base/format_macros.h"
|
| +#include "base/trace_event/trace_event_argument.h"
|
| +#include "base/values.h"
|
| +
|
| +namespace base {
|
| +namespace trace_event {
|
| +
|
| +MemoryAllocatorDump::MemoryAllocatorDump(const std::string& name,
|
| + MemoryAllocatorDump* parent)
|
| + : name_(name), parent_(parent) {
|
| +}
|
| +
|
| +MemoryAllocatorDump::~MemoryAllocatorDump() {
|
| +}
|
| +
|
| +void MemoryAllocatorDump::AsValueInto(TracedValue* value) const {
|
| + value->BeginDictionary(name_.c_str());
|
| +
|
| + value->SetString("parent", parent_ ? parent_->name_ : "");
|
| + value->SetInteger("physical_size", physical_size_in_bytes_);
|
| + value->SetInteger("allocated_objects_count", allocated_objects_count_);
|
| + value->SetInteger("allocated_objects_size", allocated_objects_size_in_bytes_);
|
| +
|
| + // Copy all the extra attributes.
|
| + value->BeginDictionary("args");
|
| + for (DictionaryValue::Iterator it(extra_attributes_); !it.IsAtEnd();
|
| + it.Advance()) {
|
| + const std::string& attr_name = it.key();
|
| + const Value& attr_value = it.value();
|
| + value->BeginDictionary(attr_name.c_str());
|
| + value->SetValue("value", attr_value.DeepCopy());
|
| +
|
| + DCHECK(extra_attributes_types_ && extra_attributes_types_->Get(attr_name));
|
| + value->SetString("type", extra_attributes_types_->Get(attr_name)->type);
|
| +
|
| + value->EndDictionary(); // "arg_name": { "type": "...", "value": "..." }
|
| + }
|
| + value->EndDictionary(); // "args": {}
|
| +
|
| + value->EndDictionary(); // "allocator name": {}
|
| +}
|
| +
|
| +} // namespace trace_event
|
| +} // namespace base
|
|
|