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

Unified Diff: base/trace_event/memory_allocator_dump.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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/memory_allocator_dump.h ('k') | base/trace_event/memory_allocator_dump_guid.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index edec31b1fdbae661bba823acddc09a7238e54b27..5d11bb006e8b0aecdcffdfbdfd7d531e6b88e75a 100644
--- a/base/trace_event/memory_allocator_dump.cc
+++ b/base/trace_event/memory_allocator_dump.cc
@@ -32,8 +32,11 @@ bool GetDictionaryValueAsCStr(const DictionaryValue* dict_value,
}
} // namespace
-const char MemoryAllocatorDump::kNameOuterSize[] = "outer_size";
+// TODO(primiano): remove kName{Inner,Outer}Size below after all the existing
+// dump providers have been rewritten.
+const char MemoryAllocatorDump::kNameSize[] = "size";
const char MemoryAllocatorDump::kNameInnerSize[] = "inner_size";
+const char MemoryAllocatorDump::kNameOuterSize[] = "outer_size";
const char MemoryAllocatorDump::kNameObjectsCount[] = "objects_count";
const char MemoryAllocatorDump::kTypeScalar[] = "scalar";
const char MemoryAllocatorDump::kTypeString[] = "string";
@@ -41,8 +44,11 @@ const char MemoryAllocatorDump::kUnitsBytes[] = "bytes";
const char MemoryAllocatorDump::kUnitsObjects[] = "objects";
MemoryAllocatorDump::MemoryAllocatorDump(const std::string& absolute_name,
- ProcessMemoryDump* process_memory_dump)
- : absolute_name_(absolute_name), process_memory_dump_(process_memory_dump) {
+ ProcessMemoryDump* process_memory_dump,
+ const MemoryAllocatorDumpGuid& guid)
+ : absolute_name_(absolute_name),
+ process_memory_dump_(process_memory_dump),
+ guid_(guid) {
// The |absolute_name| cannot be empty.
DCHECK(!absolute_name.empty());
@@ -55,6 +61,20 @@ MemoryAllocatorDump::MemoryAllocatorDump(const std::string& absolute_name,
DCHECK_EQ(std::string::npos, absolute_name.find_first_of('.'));
}
+// If the caller didn't provide a guid, make one up by hashing the
+// absolute_name with the current PID.
+// Rationale: |absolute_name| is already supposed to be unique within a
+// process, the pid will make it unique among all processes.
+MemoryAllocatorDump::MemoryAllocatorDump(const std::string& absolute_name,
+ ProcessMemoryDump* process_memory_dump)
+ : MemoryAllocatorDump(absolute_name,
+ process_memory_dump,
+ MemoryAllocatorDumpGuid(StringPrintf(
+ "%d:%s",
+ TraceLog::GetInstance()->process_id(),
+ absolute_name.c_str()))) {
+}
+
MemoryAllocatorDump::~MemoryAllocatorDump() {
}
@@ -97,6 +117,12 @@ void MemoryAllocatorDump::AddScalar(const std::string& name,
Add(name, kTypeScalar, units, hex_value.Pass());
}
+void MemoryAllocatorDump::AddScalarF(const std::string& name,
+ const char* units,
+ double value) {
+ Add(name, kTypeScalar, units, make_scoped_ptr(new FundamentalValue(value)));
+}
+
void MemoryAllocatorDump::AddString(const std::string& name,
const char* units,
const std::string& value) {
@@ -106,6 +132,8 @@ void MemoryAllocatorDump::AddString(const std::string& name,
void MemoryAllocatorDump::AsValueInto(TracedValue* value) const {
value->BeginDictionary(absolute_name_.c_str());
+ value->SetString("guid", guid_.ToString());
+
value->BeginDictionary("attrs");
for (DictionaryValue::Iterator it(attributes_); !it.IsAtEnd(); it.Advance())
« no previous file with comments | « base/trace_event/memory_allocator_dump.h ('k') | base/trace_event/memory_allocator_dump_guid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698