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