Chromium Code Reviews| 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..eb1fe7a05979fea16849986ce2de0b5b1e91392d 100644 |
| --- a/base/trace_event/heap_profiler_type_name_deduplicator.h |
| +++ b/base/trace_event/heap_profiler_type_name_deduplicator.h |
| @@ -7,34 +7,44 @@ |
| #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; |
| + TypeNameDeduplicator(StringDeduplicator* string_deduplicator); |
|
Primiano Tucci (use gerrit)
2017/03/09 11:47:45
+explicit
DmitrySkiba
2017/03/14 22:12:47
Done.
|
| + ~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 ExportIncrementally(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); |
| }; |