summaryrefslogtreecommitdiffstats
path: root/base/trace_event/memory_dump_session_state.h
blob: 6834471b9a760db062ba02cd1ef6d4f39d3082fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_TRACE_EVENT_MEMORY_DUMP_SESSION_STATE_H_
#define BASE_TRACE_EVENT_MEMORY_DUMP_SESSION_STATE_H_

#include "base/base_export.h"
#include "base/memory/ref_counted.h"
#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
#include "base/trace_event/heap_profiler_type_name_deduplicator.h"

namespace base {
namespace trace_event {

// Container for state variables that should be shared across all the memory
// dumps in a tracing session.
class BASE_EXPORT MemoryDumpSessionState
    : public RefCountedThreadSafe<MemoryDumpSessionState> {
 public:
  MemoryDumpSessionState(
      const scoped_refptr<StackFrameDeduplicator>& stack_frame_deduplicator,
      const scoped_refptr<TypeNameDeduplicator>& type_name_deduplicator);

  // Returns the stack frame deduplicator that should be used by memory dump
  // providers when doing a heap dump.
  StackFrameDeduplicator* stack_frame_deduplicator() {
    return stack_frame_deduplicator_.get();
  }

  // Returns the type name deduplicator that should be used by memory dump
  // providers when doing a heap dump.
  TypeNameDeduplicator* type_name_deduplicator() {
    return type_name_deduplicator_.get();
  }

 private:
  friend class RefCountedThreadSafe<MemoryDumpSessionState>;
  ~MemoryDumpSessionState();

  // Deduplicates backtraces in heap dumps so they can be written once when the
  // trace is finalized.
  scoped_refptr<StackFrameDeduplicator> stack_frame_deduplicator_;

  // Deduplicates type names in heap dumps so they can be written once when the
  // trace is finalized.
  scoped_refptr<TypeNameDeduplicator> type_name_deduplicator_;
};

}  // namespace trace_event
}  // namespace base

#endif  // BASE_TRACE_EVENT_MEMORY_DUMP_SESSION_STATE_H_