Chromium Code Reviews| 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 1e4d8229aef0b2a69ae9cf9f51f6547dc64203da..e737e9595534a1a4969a0e4b68260ea2dd6fb184 100644 |
| --- a/base/trace_event/memory_dump_manager.cc |
| +++ b/base/trace_event/memory_dump_manager.cc |
| @@ -317,12 +317,21 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args, |
| bool MemoryDumpManager::InvokeDumpProviderLocked(MemoryDumpProvider* mdp, |
| ProcessMemoryDump* pmd) { |
| lock_.AssertAcquired(); |
| + const int kMaxConsecutiveFailuresCount = 3; |
| bool dump_successful = mdp->OnMemoryDump(pmd); |
| + MemoryDumpProviderInfo* mdp_info = &dump_providers_.find(mdp)->second; |
| if (!dump_successful) { |
| - LOG(ERROR) << "The memory dumper failed, possibly due to sandboxing " |
| - "(crbug.com/461788), disabling it for current process. Try " |
| - "restarting chrome with the --no-sandbox switch."; |
| - dump_providers_.find(mdp)->second.disabled = true; |
| + // Disable the MDP if it fails kMaxConsecutiveFailuresCount times |
| + // consecutively. |
| + mdp_info->consecutive_failures++; |
| + if (mdp_info->consecutive_failures >= kMaxConsecutiveFailuresCount) { |
| + mdp_info->disabled = true; |
| + LOG(ERROR) << "The memory dumper failed, possibly due to sandboxing " |
| + "(crbug.com/461788), disabling it for current process. Try " |
| + "restarting chrome with the --no-sandbox switch."; |
| + } |
| + } else { |
| + mdp_info->consecutive_failures = 0; |
| } |
|
picksi
2015/06/16 12:56:44
nit: Removing the '!' and swapping the if/else bod
ssid
2015/06/16 14:52:35
Done.
|
| return dump_successful; |
| } |
| @@ -375,8 +384,10 @@ void MemoryDumpManager::OnTraceLogEnabled() { |
| } |
| session_state_ = new MemoryDumpSessionState(); |
| - for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) |
| + for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { |
| it->second.disabled = false; |
| + it->second.consecutive_failures = 0; |
| + } |
| subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); |
| @@ -396,7 +407,7 @@ void MemoryDumpManager::OnTraceLogDisabled() { |
| MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( |
| const scoped_refptr<SingleThreadTaskRunner>& task_runner) |
| - : task_runner(task_runner), disabled(false) { |
| + : task_runner(task_runner), consecutive_failures(0), disabled(false) { |
| } |
| MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { |
| } |