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

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

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « base/trace_event/memory_dump_request_args.cc ('k') | base/trace_event/trace_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PROCESS_MEMORY_DUMP_H_ 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 30 matching lines...) Expand all
41 }; 41 };
42 42
43 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to 43 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to
44 // MemoryAllocatorDump instances. 44 // MemoryAllocatorDump instances.
45 using AllocatorDumpsMap = 45 using AllocatorDumpsMap =
46 SmallMap<hash_map<std::string, MemoryAllocatorDump*>>; 46 SmallMap<hash_map<std::string, MemoryAllocatorDump*>>;
47 47
48 ProcessMemoryDump(const scoped_refptr<MemoryDumpSessionState>& session_state); 48 ProcessMemoryDump(const scoped_refptr<MemoryDumpSessionState>& session_state);
49 ~ProcessMemoryDump(); 49 ~ProcessMemoryDump();
50 50
51 // Called at trace generation time to populate the TracedValue.
52 void AsValueInto(TracedValue* value) const;
53
54 // Removes all the MemoryAllocatorDump(s) contained in this instance. This
55 // ProcessMemoryDump can be safely reused as if it was new once this returns.
56 void Clear();
57
58 // Merges all MemoryAllocatorDump(s) contained in |other| inside this
59 // ProcessMemoryDump, transferring their ownership to this instance.
60 // |other| will be an empty ProcessMemoryDump after this method returns.
61 // This is to allow dump providers to pre-populate ProcessMemoryDump instances
62 // and later move their contents into the ProcessMemoryDump passed as argument
63 // of the MemoryDumpProvider::OnMemoryDump(ProcessMemoryDump*) callback.
64 void TakeAllDumpsFrom(ProcessMemoryDump* other);
65
66 ProcessMemoryTotals* process_totals() { return &process_totals_; }
67 bool has_process_totals() const { return has_process_totals_; }
68 void set_has_process_totals() { has_process_totals_ = true; }
69
70 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
71 bool has_process_mmaps() const { return has_process_mmaps_; }
72 void set_has_process_mmaps() { has_process_mmaps_ = true; }
73
74 // Creates a new MemoryAllocatorDump with the given name and returns the 51 // Creates a new MemoryAllocatorDump with the given name and returns the
75 // empty object back to the caller. 52 // empty object back to the caller.
76 // Arguments: 53 // Arguments:
77 // absolute_name: a name that uniquely identifies allocator dumps produced 54 // absolute_name: a name that uniquely identifies allocator dumps produced
78 // by this provider. It is possible to specify nesting by using a 55 // by this provider. It is possible to specify nesting by using a
79 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). 56 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2).
80 // Leading or trailing slashes are not allowed. 57 // Leading or trailing slashes are not allowed.
81 // guid: an optional identifier, unique among all processes within the 58 // guid: an optional identifier, unique among all processes within the
82 // scope of a global dump. This is only relevant when using 59 // scope of a global dump. This is only relevant when using
83 // AddOwnershipEdge(). If omitted, it will be automatically generated. 60 // AddOwnershipEdge() to express memory sharing. If omitted,
61 // it will be automatically generated.
84 // ProcessMemoryDump handles the memory ownership of its MemoryAllocatorDumps. 62 // ProcessMemoryDump handles the memory ownership of its MemoryAllocatorDumps.
85 MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name); 63 MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name);
86 MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name, 64 MemoryAllocatorDump* CreateAllocatorDump(const std::string& absolute_name,
87 const MemoryAllocatorDumpGuid& guid); 65 const MemoryAllocatorDumpGuid& guid);
88 66
89 // Looks up a MemoryAllocatorDump given its allocator and heap names, or 67 // Looks up a MemoryAllocatorDump given its allocator and heap names, or
90 // nullptr if not found. 68 // nullptr if not found.
91 MemoryAllocatorDump* GetAllocatorDump(const std::string& absolute_name) const; 69 MemoryAllocatorDump* GetAllocatorDump(const std::string& absolute_name) const;
92 70
93 // Creates a shared MemoryAllocatorDump, to express cross-process sharing. 71 // Creates a shared MemoryAllocatorDump, to express cross-process sharing.
(...skipping 30 matching lines...) Expand all
124 // This creates a child node of |target_node_name| and adds an ownership edge 102 // This creates a child node of |target_node_name| and adds an ownership edge
125 // between |source| and the new child node. As a result, the UI will not 103 // between |source| and the new child node. As a result, the UI will not
126 // account the memory of |source| in the target node. 104 // account the memory of |source| in the target node.
127 void AddSuballocation(const MemoryAllocatorDumpGuid& source, 105 void AddSuballocation(const MemoryAllocatorDumpGuid& source,
128 const std::string& target_node_name); 106 const std::string& target_node_name);
129 107
130 const scoped_refptr<MemoryDumpSessionState>& session_state() const { 108 const scoped_refptr<MemoryDumpSessionState>& session_state() const {
131 return session_state_; 109 return session_state_;
132 } 110 }
133 111
112 // Removes all the MemoryAllocatorDump(s) contained in this instance. This
113 // ProcessMemoryDump can be safely reused as if it was new once this returns.
114 void Clear();
115
116 // Merges all MemoryAllocatorDump(s) contained in |other| inside this
117 // ProcessMemoryDump, transferring their ownership to this instance.
118 // |other| will be an empty ProcessMemoryDump after this method returns.
119 // This is to allow dump providers to pre-populate ProcessMemoryDump instances
120 // and later move their contents into the ProcessMemoryDump passed as argument
121 // of the MemoryDumpProvider::OnMemoryDump(ProcessMemoryDump*) callback.
122 void TakeAllDumpsFrom(ProcessMemoryDump* other);
123
124 // Called at trace generation time to populate the TracedValue.
125 void AsValueInto(TracedValue* value) const;
126
127 ProcessMemoryTotals* process_totals() { return &process_totals_; }
128 bool has_process_totals() const { return has_process_totals_; }
129 void set_has_process_totals() { has_process_totals_ = true; }
130
131 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
132 bool has_process_mmaps() const { return has_process_mmaps_; }
133 void set_has_process_mmaps() { has_process_mmaps_ = true; }
134
134 private: 135 private:
135 void AddAllocatorDumpInternal(MemoryAllocatorDump* mad); 136 void AddAllocatorDumpInternal(MemoryAllocatorDump* mad);
136 137
137 ProcessMemoryTotals process_totals_; 138 ProcessMemoryTotals process_totals_;
138 bool has_process_totals_; 139 bool has_process_totals_;
139 140
140 ProcessMemoryMaps process_mmaps_; 141 ProcessMemoryMaps process_mmaps_;
141 bool has_process_mmaps_; 142 bool has_process_mmaps_;
142 143
143 AllocatorDumpsMap allocator_dumps_; 144 AllocatorDumpsMap allocator_dumps_;
144 145
145 // ProcessMemoryDump handles the memory ownership of all its belongings. 146 // ProcessMemoryDump handles the memory ownership of all its belongings.
146 ScopedVector<MemoryAllocatorDump> allocator_dumps_storage_; 147 ScopedVector<MemoryAllocatorDump> allocator_dumps_storage_;
147 148
148 // State shared among all PMDs instances created in a given trace session. 149 // State shared among all PMDs instances created in a given trace session.
149 scoped_refptr<MemoryDumpSessionState> session_state_; 150 scoped_refptr<MemoryDumpSessionState> session_state_;
150 151
151 // Keeps track of relationships between MemoryAllocatorDump(s). 152 // Keeps track of relationships between MemoryAllocatorDump(s).
152 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; 153 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_;
153 154
154 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 155 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
155 }; 156 };
156 157
157 } // namespace trace_event 158 } // namespace trace_event
158 } // namespace base 159 } // namespace base
159 160
160 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 161 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_request_args.cc ('k') | base/trace_event/trace_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698