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

Side by Side Diff: base/trace_event/heap_profiler_string_deduplicator.h

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Rebase Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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_STRING_DEDUPLICATOR_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_STRING_DEDUPLICATOR_H_
7
8 #include <deque>
9 #include <string>
10 #include <unordered_map>
11
12 #include "base/base_export.h"
13 #include "base/macros.h"
14 #include "base/strings/string_piece.h"
15
16 namespace base {
17 namespace trace_event {
18
19 class TraceEventMemoryOverhead;
20 class TracedValue;
21
22 // Data structure that assigns a unique numeric ID to |const char*|s.
23 class BASE_EXPORT StringDeduplicator {
24 public:
25 StringDeduplicator();
26 ~StringDeduplicator();
27
28 // Inserts a string and returns its ID.
29 int Insert(StringPiece string);
30
31 // Append {ID -> string} mappings that were added after the last call
32 // to this function.
33 void SerializeIncrementally(TracedValue* traced_value);
34
35 // Estimates memory overhead including |sizeof(StringDeduplicator)|.
36 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead);
37
38 private:
39 // StringPieces in the map reference values from |string_|.
40 std::unordered_map<StringPiece, int, StringPieceHash> string_ids_;
41 std::deque<std::string> strings_;
42 size_t last_serialized_index_;
43
44 DISALLOW_COPY_AND_ASSIGN(StringDeduplicator);
45 };
46
47 } // namespace trace_event
48 } // namespace base
49
50 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_STRING_DEDUPLICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698