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_MEMORY_DUMP_MANAGER_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // This method takes ownership of the dump provider and guarantees that: | 107 // This method takes ownership of the dump provider and guarantees that: |
108 // - The |mdp| will be deleted at some point in the near future. | 108 // - The |mdp| will be deleted at some point in the near future. |
109 // - Its deletion will not happen concurrently with the OnMemoryDump() call. | 109 // - Its deletion will not happen concurrently with the OnMemoryDump() call. |
110 // Note that OnMemoryDump() and PollFastMemoryTotal() calls can still happen | 110 // Note that OnMemoryDump() and PollFastMemoryTotal() calls can still happen |
111 // after this method returns. | 111 // after this method returns. |
112 void UnregisterAndDeleteDumpProviderSoon( | 112 void UnregisterAndDeleteDumpProviderSoon( |
113 std::unique_ptr<MemoryDumpProvider> mdp); | 113 std::unique_ptr<MemoryDumpProvider> mdp); |
114 | 114 |
115 // Requests a memory dump. The dump might happen or not depending on the | 115 // Requests a memory dump. The dump might happen or not depending on the |
116 // filters and categories specified when enabling tracing. | 116 // filters and categories specified when enabling tracing. |
| 117 // A SUMMARY_ONLY dump can be requested at any time after initialization and |
| 118 // other type of dumps can be requested only when MDM is enabled. |
117 // The optional |callback| is executed asynchronously, on an arbitrary thread, | 119 // The optional |callback| is executed asynchronously, on an arbitrary thread, |
118 // to notify about the completion of the global dump (i.e. after all the | 120 // to notify about the completion of the global dump (i.e. after all the |
119 // processes have dumped) and its success (true iff all the dumps were | 121 // processes have dumped) and its success (true iff all the dumps were |
120 // successful). | 122 // successful). |
121 void RequestGlobalDump(MemoryDumpType dump_type, | 123 void RequestGlobalDump(MemoryDumpType dump_type, |
122 MemoryDumpLevelOfDetail level_of_detail, | 124 MemoryDumpLevelOfDetail level_of_detail, |
123 const GlobalMemoryDumpCallback& callback); | 125 const GlobalMemoryDumpCallback& callback); |
124 | 126 |
125 // Same as above (still asynchronous), but without callback. | 127 // Same as above (still asynchronous), but without callback. |
126 void RequestGlobalDump(MemoryDumpType dump_type, | 128 void RequestGlobalDump(MemoryDumpType dump_type, |
127 MemoryDumpLevelOfDetail level_of_detail); | 129 MemoryDumpLevelOfDetail level_of_detail); |
128 | 130 |
129 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls. | 131 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls for tracing |
130 // Starts the MemoryDumpManager thread. | 132 // related modes (non-SUMMARY_ONLY). |
131 // Also uses the given config to initialize the peak detector, | 133 // Initializes the peak detector, scheduler and heap profiler with the given |
132 // scheduler and heap profiler. | 134 // config. |
133 void Enable(const TraceConfig::MemoryDumpConfig&); | 135 void Enable(const TraceConfig::MemoryDumpConfig&); |
134 | 136 |
135 // Tearsdown the MemoryDumpManager thread and various other state set up by | 137 // Tear-down tracing related state. |
136 // Enable. | |
137 void Disable(); | 138 void Disable(); |
138 | 139 |
139 // NOTE: Use RequestGlobalDump() to create memory dumps. Creates a memory dump | 140 // NOTE: Use RequestGlobalDump() to create memory dumps. Creates a memory dump |
140 // for the current process and appends it to the trace. |callback| will be | 141 // for the current process and appends it to the trace. |callback| will be |
141 // invoked asynchronously upon completion on the same thread on which | 142 // invoked asynchronously upon completion on the same thread on which |
142 // CreateProcessDump() was called. This method should only be used by the | 143 // CreateProcessDump() was called. This method should only be used by the |
143 // embedder while creating a global memory dump. | 144 // embedder while creating a global memory dump. |
144 void CreateProcessDump(const MemoryDumpRequestArgs& args, | 145 void CreateProcessDump(const MemoryDumpRequestArgs& args, |
145 const ProcessMemoryDumpCallback& callback); | 146 const ProcessMemoryDumpCallback& callback); |
146 | 147 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // Function provided by the embedder to handle global dump requests. | 300 // Function provided by the embedder to handle global dump requests. |
300 RequestGlobalDumpFunction request_dump_function_; | 301 RequestGlobalDumpFunction request_dump_function_; |
301 | 302 |
302 // True when current process coordinates the periodic dump triggering. | 303 // True when current process coordinates the periodic dump triggering. |
303 bool is_coordinator_; | 304 bool is_coordinator_; |
304 | 305 |
305 // Protects from concurrent accesses to the local state, eg: to guard against | 306 // Protects from concurrent accesses to the local state, eg: to guard against |
306 // disabling logging while dumping on another thread. | 307 // disabling logging while dumping on another thread. |
307 Lock lock_; | 308 Lock lock_; |
308 | 309 |
309 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty | |
310 // dump_providers_enabled_ list) when tracing is not enabled. | |
311 subtle::AtomicWord is_enabled_; | |
312 | |
313 // Thread used for MemoryDumpProviders which don't specify a task runner | 310 // Thread used for MemoryDumpProviders which don't specify a task runner |
314 // affinity. | 311 // affinity. |
315 std::unique_ptr<Thread> dump_thread_; | 312 std::unique_ptr<Thread> dump_thread_; |
316 | 313 |
317 // The unique id of the child process. This is created only for tracing and is | 314 // The unique id of the child process. This is created only for tracing and is |
318 // expected to be valid only when tracing is enabled. | 315 // expected to be valid only when tracing is enabled. |
319 uint64_t tracing_process_id_; | 316 uint64_t tracing_process_id_; |
320 | 317 |
321 // When true, calling |RegisterMemoryDumpProvider| is a no-op. | 318 // When true, calling |RegisterMemoryDumpProvider| is a no-op. |
322 bool dumper_registrations_ignored_for_testing_; | 319 bool dumper_registrations_ignored_for_testing_; |
323 | 320 |
324 // Whether new memory dump providers should be told to enable heap profiling. | 321 // Whether new memory dump providers should be told to enable heap profiling. |
325 bool heap_profiling_enabled_; | 322 bool heap_profiling_enabled_; |
326 | 323 |
327 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 324 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
328 }; | 325 }; |
329 | 326 |
330 } // namespace trace_event | 327 } // namespace trace_event |
331 } // namespace base | 328 } // namespace base |
332 | 329 |
333 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 330 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |