| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/memory_allocator_dump.h" | 5 #include "base/trace_event/memory_allocator_dump.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/trace_event/memory_dump_manager.h" | 9 #include "base/trace_event/memory_dump_manager.h" |
| 10 #include "base/trace_event/memory_dump_provider.h" | 10 #include "base/trace_event/memory_dump_provider.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const char MemoryAllocatorDump::kTypeString[] = "string"; | 21 const char MemoryAllocatorDump::kTypeString[] = "string"; |
| 22 const char MemoryAllocatorDump::kUnitsBytes[] = "bytes"; | 22 const char MemoryAllocatorDump::kUnitsBytes[] = "bytes"; |
| 23 const char MemoryAllocatorDump::kUnitsObjects[] = "objects"; | 23 const char MemoryAllocatorDump::kUnitsObjects[] = "objects"; |
| 24 | 24 |
| 25 MemoryAllocatorDump::MemoryAllocatorDump(const std::string& absolute_name, | 25 MemoryAllocatorDump::MemoryAllocatorDump(const std::string& absolute_name, |
| 26 ProcessMemoryDump* process_memory_dump, | 26 ProcessMemoryDump* process_memory_dump, |
| 27 const MemoryAllocatorDumpGuid& guid) | 27 const MemoryAllocatorDumpGuid& guid) |
| 28 : absolute_name_(absolute_name), | 28 : absolute_name_(absolute_name), |
| 29 process_memory_dump_(process_memory_dump), | 29 process_memory_dump_(process_memory_dump), |
| 30 attributes_(new TracedValue), | 30 attributes_(new TracedValue), |
| 31 guid_(guid) { | 31 guid_(guid), |
| 32 flags_(Flags::DEFAULT) { |
| 32 // The |absolute_name| cannot be empty. | 33 // The |absolute_name| cannot be empty. |
| 33 DCHECK(!absolute_name.empty()); | 34 DCHECK(!absolute_name.empty()); |
| 34 | 35 |
| 35 // The |absolute_name| can contain slash separator, but not leading or | 36 // The |absolute_name| can contain slash separator, but not leading or |
| 36 // trailing ones. | 37 // trailing ones. |
| 37 DCHECK(absolute_name[0] != '/' && *absolute_name.rbegin() != '/'); | 38 DCHECK(absolute_name[0] != '/' && *absolute_name.rbegin() != '/'); |
| 38 } | 39 } |
| 39 | 40 |
| 40 // If the caller didn't provide a guid, make one up by hashing the | 41 // If the caller didn't provide a guid, make one up by hashing the |
| 41 // absolute_name with the current PID. | 42 // absolute_name with the current PID. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 attributes_->SetString("type", kTypeString); | 84 attributes_->SetString("type", kTypeString); |
| 84 attributes_->SetString("units", units); | 85 attributes_->SetString("units", units); |
| 85 attributes_->SetString("value", value); | 86 attributes_->SetString("value", value); |
| 86 attributes_->EndDictionary(); | 87 attributes_->EndDictionary(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void MemoryAllocatorDump::AsValueInto(TracedValue* value) const { | 90 void MemoryAllocatorDump::AsValueInto(TracedValue* value) const { |
| 90 value->BeginDictionaryWithCopiedName(absolute_name_); | 91 value->BeginDictionaryWithCopiedName(absolute_name_); |
| 91 value->SetString("guid", guid_.ToString()); | 92 value->SetString("guid", guid_.ToString()); |
| 92 value->SetValue("attrs", *attributes_); | 93 value->SetValue("attrs", *attributes_); |
| 94 if (flags_) |
| 95 value->SetInteger("flags", flags_); |
| 93 value->EndDictionary(); // "allocator_name/heap_subheap": { ... } | 96 value->EndDictionary(); // "allocator_name/heap_subheap": { ... } |
| 94 } | 97 } |
| 95 | 98 |
| 96 } // namespace trace_event | 99 } // namespace trace_event |
| 97 } // namespace base | 100 } // namespace base |
| OLD | NEW |