| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 static std::unique_ptr<MemoryDumpManager> CreateInstanceForTesting(); | 56 static std::unique_ptr<MemoryDumpManager> CreateInstanceForTesting(); |
| 57 | 57 |
| 58 // Invoked once per process to listen to trace begin / end events. | 58 // Invoked once per process to listen to trace begin / end events. |
| 59 // Initialization can happen after (Un)RegisterMemoryDumpProvider() calls | 59 // Initialization can happen after (Un)RegisterMemoryDumpProvider() calls |
| 60 // and the MemoryDumpManager guarantees to support this. | 60 // and the MemoryDumpManager guarantees to support this. |
| 61 // On the other side, the MemoryDumpManager will not be fully operational | 61 // On the other side, the MemoryDumpManager will not be fully operational |
| 62 // (i.e. will NACK any RequestGlobalMemoryDump()) until initialized. | 62 // (i.e. will NACK any RequestGlobalMemoryDump()) until initialized. |
| 63 // Arguments: | 63 // Arguments: |
| 64 // request_dump_function: Function to invoke a global dump. Global dump | 64 // request_dump_function: Function to invoke a global dump. Global dump |
| 65 // involves embedder-specific behaviors like multiprocess handshaking. | 65 // involves embedder-specific behaviors like multiprocess handshaking. |
| 66 // is_coordinator: True when current process coodinates the periodic dump | 66 // is_coordinator: True when current process coordinates the periodic dump |
| 67 // triggering. | 67 // triggering. |
| 68 void Initialize(RequestGlobalDumpFunction request_dump_function, | 68 void Initialize(RequestGlobalDumpFunction request_dump_function, |
| 69 bool is_coordinator); | 69 bool is_coordinator); |
| 70 | 70 |
| 71 // (Un)Registers a MemoryDumpProvider instance. | 71 // (Un)Registers a MemoryDumpProvider instance. |
| 72 // Args: | 72 // Args: |
| 73 // - mdp: the MemoryDumpProvider instance to be registered. MemoryDumpManager | 73 // - mdp: the MemoryDumpProvider instance to be registered. MemoryDumpManager |
| 74 // does NOT take memory ownership of |mdp|, which is expected to either | 74 // does NOT take memory ownership of |mdp|, which is expected to either |
| 75 // be a singleton or unregister itself. | 75 // be a singleton or unregister itself. |
| 76 // - name: a friendly name (duplicates allowed). Used for debugging and | 76 // - name: a friendly name (duplicates allowed). Used for debugging and |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 void set_dumper_registrations_ignored_for_testing(bool ignored) { | 171 void set_dumper_registrations_ignored_for_testing(bool ignored) { |
| 172 dumper_registrations_ignored_for_testing_ = ignored; | 172 dumper_registrations_ignored_for_testing_ = ignored; |
| 173 } | 173 } |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 friend std::default_delete<MemoryDumpManager>; // For the testing instance. | 176 friend std::default_delete<MemoryDumpManager>; // For the testing instance. |
| 177 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 177 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
| 178 friend class MemoryDumpManagerTest; | 178 friend class MemoryDumpManagerTest; |
| 179 | 179 |
| 180 // Holds the state of a process memory dump that needs to be carried over | 180 // Holds the state of a process memory dump that needs to be carried over |
| 181 // across task runners in order to fulfil an asynchronous CreateProcessDump() | 181 // across task runners in order to fulfill an asynchronous CreateProcessDump() |
| 182 // request. At any time exactly one task runner owns a | 182 // request. At any time exactly one task runner owns a |
| 183 // ProcessMemoryDumpAsyncState. | 183 // ProcessMemoryDumpAsyncState. |
| 184 struct ProcessMemoryDumpAsyncState { | 184 struct ProcessMemoryDumpAsyncState { |
| 185 ProcessMemoryDumpAsyncState( | 185 ProcessMemoryDumpAsyncState( |
| 186 MemoryDumpRequestArgs req_args, | 186 MemoryDumpRequestArgs req_args, |
| 187 const MemoryDumpProviderInfo::OrderedSet& dump_providers, | 187 const MemoryDumpProviderInfo::OrderedSet& dump_providers, |
| 188 scoped_refptr<HeapProfilerSerializationState> | 188 scoped_refptr<HeapProfilerSerializationState> |
| 189 heap_profiler_serialization_state, | 189 heap_profiler_serialization_state, |
| 190 ProcessMemoryDumpCallback callback, | 190 ProcessMemoryDumpCallback callback, |
| 191 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner); | 191 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 // Helper for the public UnregisterDumpProvider* functions. | 274 // Helper for the public UnregisterDumpProvider* functions. |
| 275 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, | 275 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, |
| 276 bool take_mdp_ownership_and_delete_async); | 276 bool take_mdp_ownership_and_delete_async); |
| 277 | 277 |
| 278 // Fills the passed vector with the subset of dump providers which were | 278 // Fills the passed vector with the subset of dump providers which were |
| 279 // registered with is_fast_polling_supported == true. | 279 // registered with is_fast_polling_supported == true. |
| 280 void GetDumpProvidersForPolling( | 280 void GetDumpProvidersForPolling( |
| 281 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); | 281 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); |
| 282 | 282 |
| 283 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task | 283 // An ordered set of registered MemoryDumpProviderInfo(s), sorted by task |
| 284 // runner affinity (MDPs belonging to the same task runners are adjacent). | 284 // runner affinity (MDPs belonging to the same task runners are adjacent). |
| 285 MemoryDumpProviderInfo::OrderedSet dump_providers_; | 285 MemoryDumpProviderInfo::OrderedSet dump_providers_; |
| 286 | 286 |
| 287 // Shared among all the PMDs to keep state scoped to the tracing session. | 287 // Shared among all the PMDs to keep state scoped to the tracing session. |
| 288 scoped_refptr<HeapProfilerSerializationState> | 288 scoped_refptr<HeapProfilerSerializationState> |
| 289 heap_profiler_serialization_state_; | 289 heap_profiler_serialization_state_; |
| 290 | 290 |
| 291 std::unique_ptr<MemoryTracingObserver> tracing_observer_; | 291 std::unique_ptr<MemoryTracingObserver> tracing_observer_; |
| 292 | 292 |
| 293 // Function provided by the embedder to handle global dump requests. | 293 // Function provided by the embedder to handle global dump requests. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 314 // Whether new memory dump providers should be told to enable heap profiling. | 314 // Whether new memory dump providers should be told to enable heap profiling. |
| 315 bool heap_profiling_enabled_; | 315 bool heap_profiling_enabled_; |
| 316 | 316 |
| 317 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 317 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
| 318 }; | 318 }; |
| 319 | 319 |
| 320 } // namespace trace_event | 320 } // namespace trace_event |
| 321 } // namespace base | 321 } // namespace base |
| 322 | 322 |
| 323 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 323 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
| OLD | NEW |