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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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_session_state.cc ('k') | base/trace_event/process_memory_dump.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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 30 matching lines...) Expand all
41 struct MemoryAllocatorDumpEdge { 41 struct MemoryAllocatorDumpEdge {
42 MemoryAllocatorDumpGuid source; 42 MemoryAllocatorDumpGuid source;
43 MemoryAllocatorDumpGuid target; 43 MemoryAllocatorDumpGuid target;
44 int importance; 44 int importance;
45 const char* type; 45 const char* type;
46 }; 46 };
47 47
48 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to 48 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to
49 // MemoryAllocatorDump instances. 49 // MemoryAllocatorDump instances.
50 using AllocatorDumpsMap = 50 using AllocatorDumpsMap =
51 std::unordered_map<std::string, scoped_ptr<MemoryAllocatorDump>>; 51 std::unordered_map<std::string, std::unique_ptr<MemoryAllocatorDump>>;
52 52
53 using HeapDumpsMap = std::unordered_map<std::string, scoped_ptr<TracedValue>>; 53 using HeapDumpsMap =
54 std::unordered_map<std::string, std::unique_ptr<TracedValue>>;
54 55
55 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) 56 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
56 // Returns the number of bytes in a kernel memory page. Some platforms may 57 // Returns the number of bytes in a kernel memory page. Some platforms may
57 // have a different value for kernel page sizes from user page sizes. It is 58 // have a different value for kernel page sizes from user page sizes. It is
58 // important to use kernel memory page sizes for resident bytes calculation. 59 // important to use kernel memory page sizes for resident bytes calculation.
59 // In most cases, the two are the same. 60 // In most cases, the two are the same.
60 static size_t GetSystemPageSize(); 61 static size_t GetSystemPageSize();
61 62
62 // Returns the total bytes resident for a virtual address range, with given 63 // Returns the total bytes resident for a virtual address range, with given
63 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The 64 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( 113 MemoryAllocatorDump* GetSharedGlobalAllocatorDump(
113 const MemoryAllocatorDumpGuid& guid) const; 114 const MemoryAllocatorDumpGuid& guid) const;
114 115
115 // Returns the map of the MemoryAllocatorDumps added to this dump. 116 // Returns the map of the MemoryAllocatorDumps added to this dump.
116 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } 117 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; }
117 118
118 // Adds a heap dump for the allocator with |absolute_name|. The |TracedValue| 119 // Adds a heap dump for the allocator with |absolute_name|. The |TracedValue|
119 // must have the correct format. |trace_event::HeapDumper| will generate such 120 // must have the correct format. |trace_event::HeapDumper| will generate such
120 // a value from a |trace_event::AllocationRegister|. 121 // a value from a |trace_event::AllocationRegister|.
121 void AddHeapDump(const std::string& absolute_name, 122 void AddHeapDump(const std::string& absolute_name,
122 scoped_ptr<TracedValue> heap_dump); 123 std::unique_ptr<TracedValue> heap_dump);
123 124
124 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the 125 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the
125 // semantics: |source| owns |target|, and has the effect of attributing 126 // semantics: |source| owns |target|, and has the effect of attributing
126 // the memory usage of |target| to |source|. |importance| is optional and 127 // the memory usage of |target| to |source|. |importance| is optional and
127 // relevant only for the cases of co-ownership, where it acts as a z-index: 128 // relevant only for the cases of co-ownership, where it acts as a z-index:
128 // the owner with the highest importance will be attributed |target|'s memory. 129 // the owner with the highest importance will be attributed |target|'s memory.
129 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, 130 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source,
130 const MemoryAllocatorDumpGuid& target, 131 const MemoryAllocatorDumpGuid& target,
131 int importance); 132 int importance);
132 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, 133 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void set_has_process_totals() { has_process_totals_ = true; } 169 void set_has_process_totals() { has_process_totals_ = true; }
169 170
170 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } 171 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
171 bool has_process_mmaps() const { return has_process_mmaps_; } 172 bool has_process_mmaps() const { return has_process_mmaps_; }
172 void set_has_process_mmaps() { has_process_mmaps_ = true; } 173 void set_has_process_mmaps() { has_process_mmaps_ = true; }
173 174
174 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } 175 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; }
175 176
176 private: 177 private:
177 MemoryAllocatorDump* AddAllocatorDumpInternal( 178 MemoryAllocatorDump* AddAllocatorDumpInternal(
178 scoped_ptr<MemoryAllocatorDump> mad); 179 std::unique_ptr<MemoryAllocatorDump> mad);
179 180
180 ProcessMemoryTotals process_totals_; 181 ProcessMemoryTotals process_totals_;
181 bool has_process_totals_; 182 bool has_process_totals_;
182 183
183 ProcessMemoryMaps process_mmaps_; 184 ProcessMemoryMaps process_mmaps_;
184 bool has_process_mmaps_; 185 bool has_process_mmaps_;
185 186
186 AllocatorDumpsMap allocator_dumps_; 187 AllocatorDumpsMap allocator_dumps_;
187 HeapDumpsMap heap_dumps_; 188 HeapDumpsMap heap_dumps_;
188 189
189 // State shared among all PMDs instances created in a given trace session. 190 // State shared among all PMDs instances created in a given trace session.
190 scoped_refptr<MemoryDumpSessionState> session_state_; 191 scoped_refptr<MemoryDumpSessionState> session_state_;
191 192
192 // Keeps track of relationships between MemoryAllocatorDump(s). 193 // Keeps track of relationships between MemoryAllocatorDump(s).
193 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; 194 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_;
194 195
195 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 196 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
196 }; 197 };
197 198
198 } // namespace trace_event 199 } // namespace trace_event
199 } // namespace base 200 } // namespace base
200 201
201 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 202 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_session_state.cc ('k') | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698