| Index: base/trace_event/memory_dump_manager.cc
|
| diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
|
| index a2628d9ed655f4a12ab81ceb7a0e491c3661c6ac..134f2c2ca7c89cfd474884e75bc9e9c80952420c 100644
|
| --- a/base/trace_event/memory_dump_manager.cc
|
| +++ b/base/trace_event/memory_dump_manager.cc
|
| @@ -150,6 +150,7 @@ MemoryDumpManager::MemoryDumpManager()
|
| : delegate_(nullptr),
|
| is_coordinator_(false),
|
| memory_tracing_enabled_(0),
|
| + periodic_dump_timer_(this),
|
| dump_provider_whitelist_(kDumpProviderWhitelist),
|
| tracing_process_id_(kInvalidTracingProcessId),
|
| dumper_registrations_ignored_for_testing_(false),
|
| @@ -356,8 +357,10 @@ void MemoryDumpManager::RequestGlobalDump(
|
| MemoryDumpType dump_type,
|
| MemoryDumpLevelOfDetail level_of_detail,
|
| const MemoryDumpCallback& callback) {
|
| - // Bail out immediately if tracing is not enabled at all.
|
| - if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
|
| + // Bail out immediately if tracing is not enabled at all or if the dump mode
|
| + // is not allowed.
|
| + if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_)) ||
|
| + !IsDumpModeAllowed(level_of_detail)) {
|
| if (!callback.is_null())
|
| callback.Run(0u /* guid */, false /* success */);
|
| return;
|
| @@ -648,6 +651,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
|
|
|
| const TraceConfig trace_config =
|
| TraceLog::GetInstance()->GetCurrentTraceConfig();
|
| + allowed_dump_modes_ = trace_config.memory_dump_config().allowed_dump_modes;
|
| scoped_refptr<MemoryDumpSessionState> session_state =
|
| new MemoryDumpSessionState;
|
| session_state->SetMemoryDumpConfig(trace_config.memory_dump_config());
|
| @@ -780,7 +784,9 @@ ProcessMemoryDump* MemoryDumpManager::ProcessMemoryDumpAsyncState::
|
| return iter->second.get();
|
| }
|
|
|
| -MemoryDumpManager::PeriodicGlobalDumpTimer::PeriodicGlobalDumpTimer() {}
|
| +MemoryDumpManager::PeriodicGlobalDumpTimer::PeriodicGlobalDumpTimer(
|
| + MemoryDumpManager* mdm)
|
| + : mdm_(mdm) {}
|
|
|
| MemoryDumpManager::PeriodicGlobalDumpTimer::~PeriodicGlobalDumpTimer() {
|
| Stop();
|
| @@ -801,12 +807,20 @@ void MemoryDumpManager::PeriodicGlobalDumpTimer::Start(
|
| DCHECK_LE(triggers_list.size(), 3u);
|
| for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) {
|
| DCHECK_NE(0u, config.periodic_interval_ms);
|
| - if (config.level_of_detail == MemoryDumpLevelOfDetail::LIGHT) {
|
| - DCHECK_EQ(0u, light_dump_period_ms);
|
| - light_dump_period_ms = config.periodic_interval_ms;
|
| - } else if (config.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
|
| - DCHECK_EQ(0u, heavy_dump_period_ms);
|
| - heavy_dump_period_ms = config.periodic_interval_ms;
|
| + switch (config.level_of_detail) {
|
| + case MemoryDumpLevelOfDetail::BACKGROUND:
|
| + DCHECK(mdm_->IsDumpModeAllowed(MemoryDumpLevelOfDetail::BACKGROUND));
|
| + break;
|
| + case MemoryDumpLevelOfDetail::LIGHT:
|
| + DCHECK_EQ(0u, light_dump_period_ms);
|
| + DCHECK(mdm_->IsDumpModeAllowed(MemoryDumpLevelOfDetail::LIGHT));
|
| + light_dump_period_ms = config.periodic_interval_ms;
|
| + break;
|
| + case MemoryDumpLevelOfDetail::DETAILED:
|
| + DCHECK_EQ(0u, heavy_dump_period_ms);
|
| + DCHECK(mdm_->IsDumpModeAllowed(MemoryDumpLevelOfDetail::DETAILED));
|
| + heavy_dump_period_ms = config.periodic_interval_ms;
|
| + break;
|
| }
|
| min_timer_period_ms =
|
| std::min(min_timer_period_ms, config.periodic_interval_ms);
|
| @@ -840,8 +854,7 @@ void MemoryDumpManager::PeriodicGlobalDumpTimer::RequestPeriodicGlobalDump() {
|
| level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
|
| ++periodic_dumps_count_;
|
|
|
| - MemoryDumpManager::GetInstance()->RequestGlobalDump(
|
| - MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
|
| + mdm_->RequestGlobalDump(MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
|
| }
|
|
|
| } // namespace trace_event
|
|
|