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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // task-runner affinity. | 106 // task-runner affinity. |
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. |
ssid
2017/05/04 22:00:22
A SUMMARY_ONLY dump can be requested at any time a
hjd
2017/05/05 14:54:52
Done.
| |
117 // The optional |callback| is executed asynchronously, on an arbitrary thread, | 117 // 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 | 118 // 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 | 119 // processes have dumped) and its success (true iff all the dumps were |
120 // successful). | 120 // successful). |
121 void RequestGlobalDump(MemoryDumpType dump_type, | 121 void RequestGlobalDump(MemoryDumpType dump_type, |
122 MemoryDumpLevelOfDetail level_of_detail, | 122 MemoryDumpLevelOfDetail level_of_detail, |
123 const GlobalMemoryDumpCallback& callback); | 123 const GlobalMemoryDumpCallback& callback); |
124 | 124 |
125 // Same as above (still asynchronous), but without callback. | 125 // Same as above (still asynchronous), but without callback. |
126 void RequestGlobalDump(MemoryDumpType dump_type, | 126 void RequestGlobalDump(MemoryDumpType dump_type, |
127 MemoryDumpLevelOfDetail level_of_detail); | 127 MemoryDumpLevelOfDetail level_of_detail); |
128 | 128 |
129 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls. | 129 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls. |
ssid
2017/05/04 22:00:22
Prepare MemoryDumpManager for RequestGlobalDump ca
hjd
2017/05/05 14:54:52
Done.
| |
130 // Starts the MemoryDumpManager thread. | 130 // Starts the MemoryDumpManager thread. |
ssid
2017/05/04 22:00:22
This comment is probably stale?
hjd
2017/05/05 14:54:52
Done, thanks!
| |
131 // Also uses the given config to initialize the peak detector, | 131 // Also uses the given config to initialize the peak detector, |
ssid
2017/05/04 22:00:22
Also uses - > Initializes the peak...
hjd
2017/05/05 14:54:52
Done.
| |
132 // scheduler and heap profiler. | 132 // scheduler and heap profiler. |
133 void Enable(const TraceConfig::MemoryDumpConfig&); | 133 void Enable(const TraceConfig::MemoryDumpConfig&); |
134 | 134 |
135 // Tearsdown the MemoryDumpManager thread and various other state set up by | 135 // Tearsdown the MemoryDumpManager thread and various other state set up by |
ssid
2017/05/04 22:00:22
remove the part about Thread.
hjd
2017/05/05 14:54:52
Done.
| |
136 // Enable. | 136 // Enable. |
137 void Disable(); | 137 void Disable(); |
138 | 138 |
139 // NOTE: Use RequestGlobalDump() to create memory dumps. Creates a memory dump | 139 // 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 | 140 // for the current process and appends it to the trace. |callback| will be |
141 // invoked asynchronously upon completion on the same thread on which | 141 // invoked asynchronously upon completion on the same thread on which |
142 // CreateProcessDump() was called. This method should only be used by the | 142 // CreateProcessDump() was called. This method should only be used by the |
143 // embedder while creating a global memory dump. | 143 // embedder while creating a global memory dump. |
144 void CreateProcessDump(const MemoryDumpRequestArgs& args, | 144 void CreateProcessDump(const MemoryDumpRequestArgs& args, |
145 const ProcessMemoryDumpCallback& callback); | 145 const ProcessMemoryDumpCallback& callback); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 // Function provided by the embedder to handle global dump requests. | 300 // Function provided by the embedder to handle global dump requests. |
301 RequestGlobalDumpFunction request_dump_function_; | 301 RequestGlobalDumpFunction request_dump_function_; |
302 | 302 |
303 // True when current process coordinates the periodic dump triggering. | 303 // True when current process coordinates the periodic dump triggering. |
304 bool is_coordinator_; | 304 bool is_coordinator_; |
305 | 305 |
306 // 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 |
307 // disabling logging while dumping on another thread. | 307 // disabling logging while dumping on another thread. |
308 Lock lock_; | 308 Lock lock_; |
309 | 309 |
310 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty | |
311 // dump_providers_enabled_ list) when tracing is not enabled. | |
312 subtle::AtomicWord is_enabled_; | |
313 | |
314 // Thread used for MemoryDumpProviders which don't specify a task runner | 310 // Thread used for MemoryDumpProviders which don't specify a task runner |
315 // affinity. | 311 // affinity. |
316 std::unique_ptr<Thread> dump_thread_; | 312 std::unique_ptr<Thread> dump_thread_; |
317 | 313 |
318 // 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 |
319 // expected to be valid only when tracing is enabled. | 315 // expected to be valid only when tracing is enabled. |
320 uint64_t tracing_process_id_; | 316 uint64_t tracing_process_id_; |
321 | 317 |
322 // When true, calling |RegisterMemoryDumpProvider| is a no-op. | 318 // When true, calling |RegisterMemoryDumpProvider| is a no-op. |
323 bool dumper_registrations_ignored_for_testing_; | 319 bool dumper_registrations_ignored_for_testing_; |
324 | 320 |
325 // 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. |
326 bool heap_profiling_enabled_; | 322 bool heap_profiling_enabled_; |
327 | 323 |
328 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 324 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
329 }; | 325 }; |
330 | 326 |
331 } // namespace trace_event | 327 } // namespace trace_event |
332 } // namespace base | 328 } // namespace base |
333 | 329 |
334 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 330 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |