OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_TYPE_NAME_DEDUPLICATOR_H_ |
| 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_TYPE_NAME_DEDUPLICATOR_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include "base/base_export.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/trace_event/trace_event_impl.h" |
| 14 |
| 15 namespace base { |
| 16 namespace trace_event { |
| 17 |
| 18 class TraceEventMemoryOverhead; |
| 19 |
| 20 // Data structure that assigns a unique numeric ID to |const char*|s. |
| 21 class BASE_EXPORT TypeNameDeduplicator : public ConvertableToTraceFormat { |
| 22 public: |
| 23 TypeNameDeduplicator(); |
| 24 |
| 25 // Inserts a type name and returns its ID. |
| 26 int Insert(const char* type_name); |
| 27 |
| 28 // Estimates memory overhead including |sizeof(TypeNameDeduplicator)|. |
| 29 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override; |
| 30 |
| 31 private: |
| 32 ~TypeNameDeduplicator() override; |
| 33 |
| 34 // Writes the type ID -> type name mapping to the trace log. |
| 35 void AppendAsTraceFormat(std::string* out) const override; |
| 36 |
| 37 // Map from type name to type ID. |
| 38 std::map<const char*, int> type_ids_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(TypeNameDeduplicator); |
| 41 }; |
| 42 |
| 43 } // namespace trace_event |
| 44 } // namespace base |
| 45 |
| 46 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_TYPE_NAME_DEDUPLICATOR_H_ |
OLD | NEW |