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

Unified Diff: base/trace_event/heap_profiler_type_name_deduplicator.h

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Address comments (heaps_v2) Created 3 years, 9 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
Index: base/trace_event/heap_profiler_type_name_deduplicator.h
diff --git a/base/trace_event/heap_profiler_type_name_deduplicator.h b/base/trace_event/heap_profiler_type_name_deduplicator.h
index 2d26c73488ef59b7e7ce8502914a54984d4666f7..17651f3c08dbf3b42c2c2b88085557de0f663a80 100644
--- a/base/trace_event/heap_profiler_type_name_deduplicator.h
+++ b/base/trace_event/heap_profiler_type_name_deduplicator.h
@@ -7,34 +7,46 @@
#include <map>
#include <string>
+#include <vector>
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/trace_event/trace_event_impl.h"
namespace base {
namespace trace_event {
+class StringDeduplicator;
class TraceEventMemoryOverhead;
+class TracedValue;
-// Data structure that assigns a unique numeric ID to |const char*|s.
-class BASE_EXPORT TypeNameDeduplicator : public ConvertableToTraceFormat {
+// Data structure that assigns a unique numeric ID to type names.
+class BASE_EXPORT TypeNameDeduplicator {
public:
- TypeNameDeduplicator();
- ~TypeNameDeduplicator() override;
+ // |string_deduplication| is used during serialization, and is expected
+ // to outlive instances of this class.
+ explicit TypeNameDeduplicator(StringDeduplicator* string_deduplicator);
+ ~TypeNameDeduplicator();
// Inserts a type name and returns its ID.
int Insert(const char* type_name);
- // Writes the type ID -> type name mapping to the trace log.
- void AppendAsTraceFormat(std::string* out) const override;
+ // Appends {ID -> type name} mappings that were added after the last call
+ // to this function. |traced_value| must be in 'array' mode.
+ void SerializeIncrementally(TracedValue* traced_value);
// Estimates memory overhead including |sizeof(TypeNameDeduplicator)|.
- void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override;
+ void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead);
private:
- // Map from type name to type ID.
- std::map<const char*, int> type_ids_;
+ StringDeduplicator* string_deduplicator_;
+
+ // Map from type name to type ID. The reason this class has its own map
+ // and does not use string_deduplicator_ in Insert() is that type names
+ // are sometimes file names, and we need post-process them to extract
+ // categories.
+ using TypeMap = std::map<const char*, int>;
+ TypeMap type_ids_;
+ std::vector<const TypeMap::value_type*> new_type_ids_;
DISALLOW_COPY_AND_ASSIGN(TypeNameDeduplicator);
};

Powered by Google App Engine
This is Rietveld 408576698