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 50171e5715f8399cb9b31b86230d39e8b273a345..6db676094fbfc1af5ae9830da8e852687d40fe58 100644 |
--- a/base/trace_event/memory_dump_manager.cc |
+++ b/base/trace_event/memory_dump_manager.cc |
@@ -131,6 +131,7 @@ MemoryDumpManager::MemoryDumpManager() |
: delegate_(nullptr), |
is_coordinator_(false), |
memory_tracing_enabled_(0), |
+ periodic_dump_timer_(this), |
tracing_process_id_(kInvalidTracingProcessId), |
dumper_registrations_ignored_for_testing_(false), |
heap_profiling_enabled_(false) { |
@@ -335,10 +336,13 @@ 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)) { |
VLOG(1) << "Global memory dump failed because " << kTraceCategory |
- << " tracing category is not enabled"; |
+ << " tracing category is not enabled or the requested dump mode is " |
+ "not allowed by trace config."; |
if (!callback.is_null()) |
callback.Run(0u /* guid */, false /* success */); |
return; |
@@ -707,6 +711,12 @@ void MemoryDumpManager::OnTraceLogDisabled() { |
dump_thread->Stop(); |
} |
+bool MemoryDumpManager::IsDumpModeAllowed( |
+ MemoryDumpLevelOfDetail dump_mode) const { |
+ return session_state_->memory_dump_config().allowed_dump_modes.count( |
Primiano Tucci (use gerrit)
2016/06/09 18:46:39
- Take the AutoLock lock(lock_); session_state is
ssid
2016/06/09 21:34:15
Fixed the lock. Also renamed the session_state get
|
+ dump_mode) != 0; |
+} |
+ |
uint64_t MemoryDumpManager::GetTracingProcessId() const { |
return delegate_->GetTracingProcessId(); |
} |
@@ -770,7 +780,9 @@ ProcessMemoryDump* MemoryDumpManager::ProcessMemoryDumpAsyncState:: |
return iter->second.get(); |
} |
-MemoryDumpManager::PeriodicGlobalDumpTimer::PeriodicGlobalDumpTimer() {} |
+MemoryDumpManager::PeriodicGlobalDumpTimer::PeriodicGlobalDumpTimer( |
+ MemoryDumpManager* mdm) |
+ : mdm_(mdm) {} |
MemoryDumpManager::PeriodicGlobalDumpTimer::~PeriodicGlobalDumpTimer() { |
Stop(); |
@@ -791,12 +803,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); |
@@ -830,8 +850,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 |