Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: base/trace_event/memory_allocator_dump.h

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/memory_allocator_dump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9a151a6f9c5e2df0960b1b56745ab1914bd539d8..2ded1733c3f97466b7737ea570150988fc16d854 100644
--- a/base/trace_event/memory_allocator_dump.h
+++ b/base/trace_event/memory_allocator_dump.h
@@ -5,9 +5,12 @@
#ifndef BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_
#define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_
+#include <string>
+
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/memory/ref_counted.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
#include "base/values.h"
@@ -29,45 +32,32 @@ class BASE_EXPORT MemoryAllocatorDump {
ProcessMemoryDump* process_memory_dump);
~MemoryAllocatorDump();
- // Standard attribute name to model allocated space.
- static const char kNameSize[];
-
- // Standard attribute name to model total space requested by the allocator
- // (e.g., amount of pages requested to the system).
- static const char kNameOuterSize[];
-
- // Standard attribute name to model space for allocated objects, without
- // taking into account allocator metadata or fragmentation.
- static const char kNameInnerSize[];
-
- // Standard attribute name to model the number of objects allocated.
- static const char kNameObjectsCount[];
+ // Standard attribute |name|s for the AddScalar and AddString() methods.
+ static const char kNameSize[]; // To represent allocated space.
+ static const char kNameObjectsCount[]; // To represent number of objects.
- static const char kTypeScalar[]; // Type name for scalar attributes.
- static const char kTypeString[]; // Type name for string attributes.
+ // Standard attribute |unit|s for the AddScalar and AddString() methods.
static const char kUnitsBytes[]; // Unit name to represent bytes.
static const char kUnitsObjects[]; // Unit name to represent #objects.
+ // Constants used only internally and by tests.
+ static const char kTypeScalar[]; // Type name for scalar attributes.
+ static const char kTypeString[]; // Type name for string attributes.
+
+ // Setters for scalar attributes. Some examples:
+ // - "size" column (all dumps are expected to have at least this one):
+ // AddScalar(kNameSize, kUnitsBytes, 1234);
+ // - Some extra-column reporting internal details of the subsystem:
+ // AddScalar("number_of_freelist_entires", kUnitsObjects, 42)
+ // - Other informational column (will not be auto-added in the UI)
+ // AddScalarF("kittens_ratio", "ratio", 42.0f)
+ void AddScalar(const char* name, const char* units, uint64 value);
+ void AddScalarF(const char* name, const char* units, double value);
+ void AddString(const char* name, const char* units, const std::string& value);
+
// 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 AddScalarF(const std::string& name, const char* units, double 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;
@@ -84,12 +74,18 @@ class BASE_EXPORT MemoryAllocatorDump {
// expected to have the same guid.
const MemoryAllocatorDumpGuid& guid() const { return guid_; }
+ TracedValue* attributes_for_testing() const { return attributes_.get(); }
+
private:
const std::string absolute_name_;
ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this).
- DictionaryValue attributes_;
+ scoped_refptr<TracedValue> attributes_;
MemoryAllocatorDumpGuid guid_;
+ // A local buffer for Sprintf conversion on fastpath. Avoids allocating
+ // temporary strings on each AddScalar() call.
+ std::string string_conversion_buffer_;
+
DISALLOW_COPY_AND_ASSIGN(MemoryAllocatorDump);
};
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/memory_allocator_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698