Index: base/trace_event/memory_dump_manager.h |
diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h |
index 817768afedd886a41db3b62cd5130ecf9530610e..2b1bb01f7677b22dfcd56ed31c16e50a48d10b7a 100644 |
--- a/base/trace_event/memory_dump_manager.h |
+++ b/base/trace_event/memory_dump_manager.h |
@@ -141,6 +141,11 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
dumper_registrations_ignored_for_testing_ = ignored; |
} |
+ // Resets the dump provider whitelist to the list given. |
+ void set_dump_provider_whitelist_for_testing(const char* const* list) { |
+ dump_provider_whitelist_ = list; |
+ } |
+ |
private: |
friend std::default_delete<MemoryDumpManager>; // For the testing instance. |
friend struct DefaultSingletonTraits<MemoryDumpManager>; |
@@ -176,7 +181,8 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
MemoryDumpProviderInfo(MemoryDumpProvider* dump_provider, |
const char* name, |
scoped_refptr<SequencedTaskRunner> task_runner, |
- const MemoryDumpProvider::Options& options); |
+ const MemoryDumpProvider::Options& options, |
+ bool whitelisted_for_background_mode); |
MemoryDumpProvider* const dump_provider; |
@@ -200,6 +206,9 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
// Flagged either by the auto-disable logic or during unregistration. |
bool disabled; |
+ // True if the dump provider is whitelisted for background mode. |
+ const bool whitelisted_for_background_mode; |
+ |
private: |
friend class base::RefCountedThreadSafe<MemoryDumpProviderInfo>; |
~MemoryDumpProviderInfo(); |
@@ -262,6 +271,31 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState); |
}; |
+ // Sets up periodic memory dump timers to start global dump requests based on |
+ // the dump triggers from trace config. |
+ class BASE_EXPORT PeriodicGlobalDumpTimer { |
+ public: |
+ PeriodicGlobalDumpTimer(); |
+ ~PeriodicGlobalDumpTimer(); |
+ |
+ void Start(const std::vector<TraceConfig::MemoryDumpConfig::Trigger>& |
+ triggers_list); |
+ void Stop(); |
+ |
+ bool IsRunning(); |
+ |
+ private: |
+ // Periodically called by the timer. |
+ void RequestPeriodicGlobalDump(); |
+ |
+ RepeatingTimer timer_; |
+ uint32_t periodic_dumps_count_; |
+ uint32_t light_dump_rate_; |
+ uint32_t heavy_dump_rate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PeriodicGlobalDumpTimer); |
+ }; |
+ |
static const int kMaxConsecutiveFailuresCount; |
static const char* const kSystemAllocatorPoolName; |
@@ -325,12 +359,15 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
subtle::AtomicWord memory_tracing_enabled_; |
// For time-triggered periodic dumps. |
- RepeatingTimer periodic_dump_timer_; |
+ PeriodicGlobalDumpTimer periodic_dump_timer_; |
// Thread used for MemoryDumpProviders which don't specify a task runner |
// affinity. |
std::unique_ptr<Thread> dump_thread_; |
+ // List of names of the dump providers whitelisted for background mode. |
+ const char* const* dump_provider_whitelist_; |
+ |
// The unique id of the child process. This is created only for tracing and is |
// expected to be valid only when tracing is enabled. |
uint64_t tracing_process_id_; |