| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void RequestGlobalDump(MemoryDumpType dump_type, | 119 void RequestGlobalDump(MemoryDumpType dump_type, |
| 120 MemoryDumpLevelOfDetail level_of_detail); | 120 MemoryDumpLevelOfDetail level_of_detail); |
| 121 | 121 |
| 122 // TraceLog::EnabledStateObserver implementation. | 122 // TraceLog::EnabledStateObserver implementation. |
| 123 void OnTraceLogEnabled() override; | 123 void OnTraceLogEnabled() override; |
| 124 void OnTraceLogDisabled() override; | 124 void OnTraceLogDisabled() override; |
| 125 | 125 |
| 126 // Enable heap profiling if kEnableHeapProfiling is specified. | 126 // Enable heap profiling if kEnableHeapProfiling is specified. |
| 127 void EnableHeapProfilingIfNeeded(); | 127 void EnableHeapProfilingIfNeeded(); |
| 128 | 128 |
| 129 // Enable heap profiling with specified |capture_mode|. Disabling heap |
| 130 // profiler will disable it permanently and cannot be enabled again. |
| 131 void EnableHeapProfiling(AllocationContextTracker::CaptureMode capture_mode); |
| 132 |
| 129 // Returns true if the dump mode is allowed for current tracing session. | 133 // Returns true if the dump mode is allowed for current tracing session. |
| 130 bool IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode); | 134 bool IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode); |
| 131 | 135 |
| 132 // Lets tests see if a dump provider is registered. | 136 // Lets tests see if a dump provider is registered. |
| 133 bool IsDumpProviderRegisteredForTesting(MemoryDumpProvider*); | 137 bool IsDumpProviderRegisteredForTesting(MemoryDumpProvider*); |
| 134 | 138 |
| 135 // Returns the MemoryDumpSessionState object, which is shared by all the | 139 // Returns the MemoryDumpSessionState object, which is shared by all the |
| 136 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing | 140 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing |
| 137 // session lifetime. | 141 // session lifetime. |
| 138 const scoped_refptr<MemoryDumpSessionState>& session_state_for_testing() | 142 const scoped_refptr<MemoryDumpSessionState>& session_state_for_testing() |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, | 343 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, |
| 340 bool take_mdp_ownership_and_delete_async); | 344 bool take_mdp_ownership_and_delete_async); |
| 341 | 345 |
| 342 // Adds / removes provider that supports polling to | 346 // Adds / removes provider that supports polling to |
| 343 // |dump_providers_for_polling_|. | 347 // |dump_providers_for_polling_|. |
| 344 void RegisterPollingMDPOnDumpThread( | 348 void RegisterPollingMDPOnDumpThread( |
| 345 scoped_refptr<MemoryDumpProviderInfo> mdpinfo); | 349 scoped_refptr<MemoryDumpProviderInfo> mdpinfo); |
| 346 void UnregisterPollingMDPOnDumpThread( | 350 void UnregisterPollingMDPOnDumpThread( |
| 347 scoped_refptr<MemoryDumpProviderInfo> mdpinfo); | 351 scoped_refptr<MemoryDumpProviderInfo> mdpinfo); |
| 348 | 352 |
| 353 // Helper to enable heap profiling. |
| 354 void EnableHeapProfilingLocked( |
| 355 AllocationContextTracker::CaptureMode capture_mode); |
| 356 |
| 349 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task | 357 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task |
| 350 // runner affinity (MDPs belonging to the same task runners are adjacent). | 358 // runner affinity (MDPs belonging to the same task runners are adjacent). |
| 351 MemoryDumpProviderInfo::OrderedSet dump_providers_; | 359 MemoryDumpProviderInfo::OrderedSet dump_providers_; |
| 352 | 360 |
| 353 // A copy of mdpinfo list that support polling. It must be accessed only on | 361 // A copy of mdpinfo list that support polling. It must be accessed only on |
| 354 // the dump thread if dump thread exists. | 362 // the dump thread if dump thread exists. |
| 355 MemoryDumpProviderInfo::OrderedSet dump_providers_for_polling_; | 363 MemoryDumpProviderInfo::OrderedSet dump_providers_for_polling_; |
| 356 | 364 |
| 357 // Shared among all the PMDs to keep state scoped to the tracing session. | 365 // Shared among all the PMDs to keep state scoped to the tracing session. |
| 358 scoped_refptr<MemoryDumpSessionState> session_state_; | 366 scoped_refptr<MemoryDumpSessionState> session_state_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 376 // affinity. | 384 // affinity. |
| 377 std::unique_ptr<Thread> dump_thread_; | 385 std::unique_ptr<Thread> dump_thread_; |
| 378 | 386 |
| 379 // The unique id of the child process. This is created only for tracing and is | 387 // The unique id of the child process. This is created only for tracing and is |
| 380 // expected to be valid only when tracing is enabled. | 388 // expected to be valid only when tracing is enabled. |
| 381 uint64_t tracing_process_id_; | 389 uint64_t tracing_process_id_; |
| 382 | 390 |
| 383 // When true, calling |RegisterMemoryDumpProvider| is a no-op. | 391 // When true, calling |RegisterMemoryDumpProvider| is a no-op. |
| 384 bool dumper_registrations_ignored_for_testing_; | 392 bool dumper_registrations_ignored_for_testing_; |
| 385 | 393 |
| 386 // Whether new memory dump providers should be told to enable heap profiling. | 394 // Heap profiling can be enabled and disabled only once in the process. |
| 387 bool heap_profiling_enabled_; | 395 // New memory dump providers should be told to enable heap profiling if state |
| 396 // is ENABLED. |
| 397 enum class HeapProfilingState { DISABLED, ENABLED, DISABLED_PERMANENTLY }; |
| 398 HeapProfilingState heap_profiling_state_; |
| 388 | 399 |
| 389 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 400 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
| 390 }; | 401 }; |
| 391 | 402 |
| 392 // The delegate is supposed to be long lived (read: a Singleton) and thread | 403 // The delegate is supposed to be long lived (read: a Singleton) and thread |
| 393 // safe (i.e. should expect calls from any thread and handle thread hopping). | 404 // safe (i.e. should expect calls from any thread and handle thread hopping). |
| 394 class BASE_EXPORT MemoryDumpManagerDelegate { | 405 class BASE_EXPORT MemoryDumpManagerDelegate { |
| 395 public: | 406 public: |
| 396 MemoryDumpManagerDelegate() {} | 407 MemoryDumpManagerDelegate() {} |
| 397 virtual ~MemoryDumpManagerDelegate() {} | 408 virtual ~MemoryDumpManagerDelegate() {} |
| (...skipping 10 matching lines...) Expand all Loading... |
| 408 } | 419 } |
| 409 | 420 |
| 410 private: | 421 private: |
| 411 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 422 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
| 412 }; | 423 }; |
| 413 | 424 |
| 414 } // namespace trace_event | 425 } // namespace trace_event |
| 415 } // namespace base | 426 } // namespace base |
| 416 | 427 |
| 417 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 428 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
| OLD | NEW |