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 28 matching lines...) Expand all Loading... |
39 // This is the interface exposed to the rest of the codebase to deal with | 39 // This is the interface exposed to the rest of the codebase to deal with |
40 // memory tracing. The main entry point for clients is represented by | 40 // memory tracing. The main entry point for clients is represented by |
41 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). | 41 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). |
42 class BASE_EXPORT MemoryDumpManager { | 42 class BASE_EXPORT MemoryDumpManager { |
43 public: | 43 public: |
44 using RequestGlobalDumpFunction = | 44 using RequestGlobalDumpFunction = |
45 RepeatingCallback<void(const MemoryDumpRequestArgs& args, | 45 RepeatingCallback<void(const MemoryDumpRequestArgs& args, |
46 const GlobalMemoryDumpCallback& callback)>; | 46 const GlobalMemoryDumpCallback& callback)>; |
47 | 47 |
48 static const char* const kTraceCategory; | 48 static const char* const kTraceCategory; |
49 static const char* const kLogPrefix; | |
50 | 49 |
51 // This value is returned as the tracing id of the child processes by | 50 // This value is returned as the tracing id of the child processes by |
52 // GetTracingProcessId() when tracing is not enabled. | 51 // GetTracingProcessId() when tracing is not enabled. |
53 static const uint64_t kInvalidTracingProcessId; | 52 static const uint64_t kInvalidTracingProcessId; |
54 | 53 |
55 static MemoryDumpManager* GetInstance(); | 54 static MemoryDumpManager* GetInstance(); |
56 static std::unique_ptr<MemoryDumpManager> CreateInstanceForTesting(); | 55 static std::unique_ptr<MemoryDumpManager> CreateInstanceForTesting(); |
57 | 56 |
58 // Invoked once per process to listen to trace begin / end events. | 57 // Invoked once per process to listen to trace begin / end events. |
59 // Initialization can happen after (Un)RegisterMemoryDumpProvider() calls | 58 // Initialization can happen after (Un)RegisterMemoryDumpProvider() calls |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 std::unique_ptr<MemoryDumpProvider> mdp); | 105 std::unique_ptr<MemoryDumpProvider> mdp); |
107 | 106 |
108 // Requests a memory dump. The dump might happen or not depending on the | 107 // Requests a memory dump. The dump might happen or not depending on the |
109 // filters and categories specified when enabling tracing. | 108 // filters and categories specified when enabling tracing. |
110 // A SUMMARY_ONLY dump can be requested at any time after initialization and | 109 // A SUMMARY_ONLY dump can be requested at any time after initialization and |
111 // other type of dumps can be requested only when MDM is enabled. | 110 // other type of dumps can be requested only when MDM is enabled. |
112 // The optional |callback| is executed asynchronously, on an arbitrary thread, | 111 // The optional |callback| is executed asynchronously, on an arbitrary thread, |
113 // to notify about the completion of the global dump (i.e. after all the | 112 // to notify about the completion of the global dump (i.e. after all the |
114 // processes have dumped) and its success (true iff all the dumps were | 113 // processes have dumped) and its success (true iff all the dumps were |
115 // successful). | 114 // successful). |
116 void RequestGlobalDump(MemoryDumpType dump_type, | 115 void RequestGlobalDump(MemoryDumpType, |
117 MemoryDumpLevelOfDetail level_of_detail, | 116 MemoryDumpLevelOfDetail, |
118 const GlobalMemoryDumpCallback& callback); | 117 const GlobalMemoryDumpCallback&); |
119 | 118 |
120 // Same as above (still asynchronous), but without callback. | 119 // Same as above (still asynchronous), but without callback. |
121 void RequestGlobalDump(MemoryDumpType dump_type, | 120 void RequestGlobalDump(MemoryDumpType, MemoryDumpLevelOfDetail); |
122 MemoryDumpLevelOfDetail level_of_detail); | |
123 | 121 |
124 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls for tracing | 122 // Prepare MemoryDumpManager for RequestGlobalMemoryDump calls for tracing |
125 // related modes (non-SUMMARY_ONLY). | 123 // related modes (non-SUMMARY_ONLY). |
126 // Initializes the peak detector, scheduler and heap profiler with the given | 124 // Initializes the peak detector, scheduler and heap profiler with the given |
127 // config. | 125 // config. |
128 void SetupForTracing(const TraceConfig::MemoryDumpConfig&); | 126 void SetupForTracing(const TraceConfig::MemoryDumpConfig&); |
129 | 127 |
130 // Tear-down tracing related state. | 128 // Tear-down tracing related state. |
131 // Non-tracing modes (e.g. SUMMARY_ONLY) will continue to work. | 129 // Non-tracing modes (e.g. SUMMARY_ONLY) will continue to work. |
132 void TeardownForTracing(); | 130 void TeardownForTracing(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 271 |
274 // Helper for the public UnregisterDumpProvider* functions. | 272 // Helper for the public UnregisterDumpProvider* functions. |
275 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, | 273 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, |
276 bool take_mdp_ownership_and_delete_async); | 274 bool take_mdp_ownership_and_delete_async); |
277 | 275 |
278 // Fills the passed vector with the subset of dump providers which were | 276 // Fills the passed vector with the subset of dump providers which were |
279 // registered with is_fast_polling_supported == true. | 277 // registered with is_fast_polling_supported == true. |
280 void GetDumpProvidersForPolling( | 278 void GetDumpProvidersForPolling( |
281 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); | 279 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); |
282 | 280 |
| 281 // Returns true if Initialize() has been called, false otherwise. |
| 282 bool is_initialized() const { return !request_dump_function_.is_null(); } |
| 283 |
283 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task | 284 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task |
284 // runner affinity (MDPs belonging to the same task runners are adjacent). | 285 // runner affinity (MDPs belonging to the same task runners are adjacent). |
285 MemoryDumpProviderInfo::OrderedSet dump_providers_; | 286 MemoryDumpProviderInfo::OrderedSet dump_providers_; |
286 | 287 |
287 // Shared among all the PMDs to keep state scoped to the tracing session. | 288 // Shared among all the PMDs to keep state scoped to the tracing session. |
288 scoped_refptr<HeapProfilerSerializationState> | 289 scoped_refptr<HeapProfilerSerializationState> |
289 heap_profiler_serialization_state_; | 290 heap_profiler_serialization_state_; |
290 | 291 |
291 std::unique_ptr<MemoryTracingObserver> tracing_observer_; | 292 std::unique_ptr<MemoryTracingObserver> tracing_observer_; |
292 | 293 |
(...skipping 21 matching lines...) Expand all Loading... |
314 // Whether new memory dump providers should be told to enable heap profiling. | 315 // Whether new memory dump providers should be told to enable heap profiling. |
315 bool heap_profiling_enabled_; | 316 bool heap_profiling_enabled_; |
316 | 317 |
317 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 318 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
318 }; | 319 }; |
319 | 320 |
320 } // namespace trace_event | 321 } // namespace trace_event |
321 } // namespace base | 322 } // namespace base |
322 | 323 |
323 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 324 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |