| 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 "base/trace_event/memory_allocator_dump.h" |
| 6 |
| 7 #include "base/format_macros.h" |
| 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "base/values.h" |
| 10 |
| 11 namespace base { |
| 12 namespace trace_event { |
| 13 |
| 14 MemoryAllocatorDump::MemoryAllocatorDump(const std::string& name, |
| 15 MemoryAllocatorDump* parent) |
| 16 : name_(name), parent_(parent) { |
| 17 } |
| 18 |
| 19 MemoryAllocatorDump::~MemoryAllocatorDump() { |
| 20 } |
| 21 |
| 22 void MemoryAllocatorDump::AsValueInto(TracedValue* value) const { |
| 23 value->BeginDictionary(name_.c_str()); |
| 24 |
| 25 value->SetString("parent", parent_ ? parent_->name_ : ""); |
| 26 value->SetInteger("physical_size", physical_size_in_bytes_); |
| 27 value->SetInteger("allocated_objects_count", allocated_objects_count_); |
| 28 value->SetInteger("allocated_objects_size", allocated_objects_size_in_bytes_); |
| 29 |
| 30 // Copy all the extra attributes. |
| 31 value->BeginDictionary("args"); |
| 32 for (DictionaryValue::Iterator it(extra_attributes_); !it.IsAtEnd(); |
| 33 it.Advance()) { |
| 34 const std::string& attr_name = it.key(); |
| 35 const Value& attr_value = it.value(); |
| 36 value->BeginDictionary(attr_name.c_str()); |
| 37 value->SetValue("value", attr_value.DeepCopy()); |
| 38 |
| 39 DCHECK(extra_attributes_types_ && extra_attributes_types_->Get(attr_name)); |
| 40 value->SetString("type", extra_attributes_types_->Get(attr_name)->type); |
| 41 |
| 42 value->EndDictionary(); // "arg_name": { "type": "...", "value": "..." } |
| 43 } |
| 44 value->EndDictionary(); // "args": {} |
| 45 |
| 46 value->EndDictionary(); // "allocator name": {} |
| 47 } |
| 48 |
| 49 } // namespace trace_event |
| 50 } // namespace base |
| OLD | NEW |