Index: base/trace_event/memory_allocator_dump.h |
diff --git a/base/trace_event/memory_allocator_dump.h b/base/trace_event/memory_allocator_dump.h |
index 1c786ab032ccba06fc3bba14baab9aee1fa63526..1bb27f952e1a0be5202980efa94b3dbb90fbaa1b 100644 |
--- a/base/trace_event/memory_allocator_dump.h |
+++ b/base/trace_event/memory_allocator_dump.h |
@@ -8,7 +8,6 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
#include "base/logging.h" |
-#include "base/trace_event/memory_allocator_attributes_type_info.h" |
#include "base/values.h" |
namespace base { |
@@ -21,58 +20,45 @@ class TracedValue; |
// Data model for user-land memory allocator dumps. |
class BASE_EXPORT MemoryAllocatorDump { |
public: |
- // Returns the absolute name for a given (|allocator_name|,|heap_name|) tuple. |
- static std::string GetAbsoluteName(const std::string& allocator_name, |
- const std::string& heap_name); |
- |
- // Use as argument for |heap_name| when the allocator has only one root heap. |
- static const char kRootHeap[]; |
- |
// MemoryAllocatorDump is owned by ProcessMemoryDump. |
- MemoryAllocatorDump(const std::string& allocator_name, |
- const std::string& heap_name, |
+ MemoryAllocatorDump(const std::string& absolute_name, |
ProcessMemoryDump* process_memory_dump); |
~MemoryAllocatorDump(); |
- // Name of the allocator, a plain string with no separators (e.g, "malloc"). |
- const std::string& allocator_name() const { return allocator_name_; } |
+ // Standard attribute name to model total space requested by the allocator |
+ // (e.g., amount of pages requested to the system). |
+ static const char kNameOuterSize[]; |
- // Name of the heap being dumped, either: "heap", "heap/subheap" or kRootHeap |
- // if the allocator has just one root heap. |
- const std::string& heap_name() const { return heap_name_; } |
+ // Standard attribute name to model space for allocated objects, without |
+ // taking into account allocator metadata or fragmentation. |
+ static const char kNameInnerSize[]; |
- // Absolute name, unique within the scope of an entire ProcessMemoryDump. |
- // In practice this is "allocator_name/heap/subheap". |
- std::string GetAbsoluteName() const; |
+ // Standard attribute name to model the number of objects allocated. |
+ static const char kNameObjectsCount[]; |
- // Inner size: Bytes requested by clients of the allocator, without accounting |
- // for any metadata or allocator-specific bookeeping structs. |
- void set_allocated_objects_size_in_bytes(uint64 value) { |
- allocated_objects_size_in_bytes_ = value; |
- } |
- uint64 allocated_objects_size_in_bytes() const { |
- return allocated_objects_size_in_bytes_; |
- } |
+ static const char kTypeScalar[]; // Type name for scalar attributes. |
+ static const char kTypeString[]; // Type name for string attributes. |
+ static const char kUnitsBytes[]; // Unit name to represent bytes. |
+ static const char kUnitsObjects[]; // Unit name to represent #objects. |
- // Outer size: bytes requested to the system to handle all the allocations, |
- // including any allocator-internal metadata / bookeeping structs. For |
- // instance, in the case of an allocator which gets pages to the system via |
- // mmap() or similar, this is the number of requested pages * 4k. |
- void set_physical_size_in_bytes(uint64 value) { |
- physical_size_in_bytes_ = value; |
- } |
- uint64 physical_size_in_bytes() const { return physical_size_in_bytes_; } |
- |
- // Number of objects allocated, if known, or 0 if not available. |
- void set_allocated_objects_count(uint64 value) { |
- allocated_objects_count_ = value; |
- } |
- uint64 allocated_objects_count() const { return allocated_objects_count_; } |
- |
- // Get/Set extra attributes. The attributes name must have been previously |
- // declared through MemoryDumpProvider.DeclareAllocatorAttribute(). |
- void SetAttribute(const std::string& name, int value); |
- int GetIntegerAttribute(const std::string& name) const; |
+ // Absolute name, unique within the scope of an entire ProcessMemoryDump. |
+ const std::string& absolute_name() const { return absolute_name_; } |
+ |
+ // Generic attribute setter / getter. |
+ void Add(const std::string& name, |
+ const char* type, |
+ const char* units, |
+ scoped_ptr<Value> value); |
+ bool Get(const std::string& name, |
+ const char** out_type, |
+ const char** out_units, |
+ const Value** out_value) const; |
+ |
+ // Helper setter for scalar attributes. |
+ void AddScalar(const std::string& name, const char* units, uint64 value); |
+ void AddString(const std::string& name, |
+ const char* units, |
+ const std::string& value); |
// Called at trace generation time to populate the TracedValue. |
void AsValueInto(TracedValue* value) const; |
@@ -82,18 +68,10 @@ class BASE_EXPORT MemoryAllocatorDump { |
return process_memory_dump_; |
} |
- // Retrieves the map of allocator attributes types, which is shared by all |
- // MemoryAllocatorDump(s) across all ProcessMemoryDump(s) per tracing session. |
- const MemoryAllocatorAttributesTypeInfo& GetAttributesTypeInfo() const; |
- |
private: |
- const std::string allocator_name_; |
- const std::string heap_name_; |
+ const std::string absolute_name_; |
ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this). |
- uint64 physical_size_in_bytes_; |
- uint64 allocated_objects_count_; |
- uint64 allocated_objects_size_in_bytes_; |
- DictionaryValue attributes_values_; |
+ DictionaryValue attributes_; |
DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump); |
}; |