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_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 <map> | 10 #include <map> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/trace_event/process_memory_totals.h" | 23 #include "base/trace_event/process_memory_totals.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 | 25 |
26 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the | 26 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the |
27 // resident memory. | 27 // resident memory. |
28 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) | 28 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) |
29 #define COUNT_RESIDENT_BYTES_SUPPORTED | 29 #define COUNT_RESIDENT_BYTES_SUPPORTED |
30 #endif | 30 #endif |
31 | 31 |
32 namespace base { | 32 namespace base { |
| 33 |
| 34 class UnguessableToken; |
| 35 |
33 namespace trace_event { | 36 namespace trace_event { |
34 | 37 |
35 class HeapProfilerSerializationState; | 38 class HeapProfilerSerializationState; |
36 class TracedValue; | 39 class TracedValue; |
37 | 40 |
38 // ProcessMemoryDump is as a strongly typed container which holds the dumps | 41 // ProcessMemoryDump is as a strongly typed container which holds the dumps |
39 // produced by the MemoryDumpProvider(s) for a specific process. | 42 // produced by the MemoryDumpProvider(s) for a specific process. |
40 class BASE_EXPORT ProcessMemoryDump { | 43 class BASE_EXPORT ProcessMemoryDump { |
41 public: | 44 public: |
42 struct MemoryAllocatorDumpEdge { | 45 struct MemoryAllocatorDumpEdge { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 146 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
144 const MemoryAllocatorDumpGuid& target); | 147 const MemoryAllocatorDumpGuid& target); |
145 | 148 |
146 // Adds edges that can be overriden by a later or earlier call to | 149 // Adds edges that can be overriden by a later or earlier call to |
147 // AddOwnershipEdge() with the same source and target with a different | 150 // AddOwnershipEdge() with the same source and target with a different |
148 // |importance| value. | 151 // |importance| value. |
149 void AddOverridableOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 152 void AddOverridableOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
150 const MemoryAllocatorDumpGuid& target, | 153 const MemoryAllocatorDumpGuid& target, |
151 int importance); | 154 int importance); |
152 | 155 |
| 156 // Creates ownership edges for memory backed by base::SharedMemory. Handles |
| 157 // the case of cross process sharing and importnace of ownership for the case |
| 158 // with and without the base::SharedMemory dump provider. The new version |
| 159 // should just use global dumps created by SharedMemoryTracker and this |
| 160 // function handles the transition until we get SharedMemory IDs through mojo |
| 161 // channel crbug.com/713763. The weak version creates a weak global dump. |
| 162 // |client_local_dump_guid| The guid of the local dump created by the client |
| 163 // of base::SharedMemory. |
| 164 // |client_global_dump_guid| The global guid given by the clients to create |
| 165 // ownership edges of their own. These global dumps will no longer be required |
| 166 // after the transition. |
| 167 // |shared_memory_guid| The ID of the base::SharedMemory that is assigned |
| 168 // globally, used to create global dump edges in the new model. |
| 169 // |importance| Importance of the global dump edges to say if the current |
| 170 // process owns the memory segment. |
| 171 void CreateSharedMemoryOwnershipEdge( |
| 172 const MemoryAllocatorDumpGuid& client_local_dump_guid, |
| 173 const MemoryAllocatorDumpGuid& client_global_dump_guid, |
| 174 const UnguessableToken& shared_memory_guid, |
| 175 int importance); |
| 176 void CreateWeakSharedMemoryOwnershipEdge( |
| 177 const MemoryAllocatorDumpGuid& client_local_dump_guid, |
| 178 const MemoryAllocatorDumpGuid& client_global_dump_guid, |
| 179 const UnguessableToken& shared_memory_guid, |
| 180 int importance); |
| 181 |
153 const AllocatorDumpEdgesMap& allocator_dumps_edges_for_testing() const { | 182 const AllocatorDumpEdgesMap& allocator_dumps_edges_for_testing() const { |
154 return allocator_dumps_edges_; | 183 return allocator_dumps_edges_; |
155 } | 184 } |
156 | 185 |
157 // Utility method to add a suballocation relationship with the following | 186 // Utility method to add a suballocation relationship with the following |
158 // semantics: |source| is suballocated from |target_node_name|. | 187 // semantics: |source| is suballocated from |target_node_name|. |
159 // This creates a child node of |target_node_name| and adds an ownership edge | 188 // This creates a child node of |target_node_name| and adds an ownership edge |
160 // between |source| and the new child node. As a result, the UI will not | 189 // between |source| and the new child node. As a result, the UI will not |
161 // account the memory of |source| in the target node. | 190 // account the memory of |source| in the target node. |
162 void AddSuballocation(const MemoryAllocatorDumpGuid& source, | 191 void AddSuballocation(const MemoryAllocatorDumpGuid& source, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } | 223 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } |
195 | 224 |
196 const MemoryDumpArgs& dump_args() const { return dump_args_; } | 225 const MemoryDumpArgs& dump_args() const { return dump_args_; } |
197 | 226 |
198 private: | 227 private: |
199 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest); | 228 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest); |
200 | 229 |
201 MemoryAllocatorDump* AddAllocatorDumpInternal( | 230 MemoryAllocatorDump* AddAllocatorDumpInternal( |
202 std::unique_ptr<MemoryAllocatorDump> mad); | 231 std::unique_ptr<MemoryAllocatorDump> mad); |
203 | 232 |
| 233 void CreateSharedMemoryOwnershipEdgeInternal( |
| 234 const MemoryAllocatorDumpGuid& client_local_dump_guid, |
| 235 const MemoryAllocatorDumpGuid& client_global_dump_guid, |
| 236 const UnguessableToken& shared_memory_guid, |
| 237 int importance, |
| 238 bool is_weak); |
| 239 |
204 MemoryAllocatorDump* GetBlackHoleMad(); | 240 MemoryAllocatorDump* GetBlackHoleMad(); |
205 | 241 |
206 ProcessMemoryTotals process_totals_; | 242 ProcessMemoryTotals process_totals_; |
207 bool has_process_totals_; | 243 bool has_process_totals_; |
208 | 244 |
209 ProcessMemoryMaps process_mmaps_; | 245 ProcessMemoryMaps process_mmaps_; |
210 bool has_process_mmaps_; | 246 bool has_process_mmaps_; |
211 | 247 |
212 AllocatorDumpsMap allocator_dumps_; | 248 AllocatorDumpsMap allocator_dumps_; |
213 HeapDumpsMap heap_dumps_; | 249 HeapDumpsMap heap_dumps_; |
(...skipping 17 matching lines...) Expand all Loading... |
231 // background mode are disabled for testing. | 267 // background mode are disabled for testing. |
232 static bool is_black_hole_non_fatal_for_testing_; | 268 static bool is_black_hole_non_fatal_for_testing_; |
233 | 269 |
234 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 270 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
235 }; | 271 }; |
236 | 272 |
237 } // namespace trace_event | 273 } // namespace trace_event |
238 } // namespace base | 274 } // namespace base |
239 | 275 |
240 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 276 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
OLD | NEW |