Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1655)

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 1152743003: Making the MemoryDumpManager less aggressive in disabling dump providers on failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 82fe10a0f64053626ef546dd77a839dd7915d6b6..61e5d19902bbb16a9db6b548a83fd0d78d42f910 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -153,6 +153,9 @@ void InitializeThreadLocalEventBufferIfSupported() {
const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory;
// static
+const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
+
+// static
MemoryDumpManager* MemoryDumpManager::GetInstance() {
if (g_instance_for_testing)
return g_instance_for_testing;
@@ -349,11 +352,19 @@ bool MemoryDumpManager::InvokeDumpProviderLocked(MemoryDumpProvider* mdp,
ProcessMemoryDump* pmd) {
lock_.AssertAcquired();
bool dump_successful = mdp->OnMemoryDump(pmd);
- 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;
+ MemoryDumpProviderInfo* mdp_info = &dump_providers_.find(mdp)->second;
+ if (dump_successful) {
+ mdp_info->consecutive_failures = 0;
+ } else {
+ // 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.";
+ }
}
return dump_successful;
}
@@ -409,6 +420,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) {
MemoryDumpProviderInfo& mdp_info = it->second;
mdp_info.disabled = false;
+ mdp_info.consecutive_failures = 0;
if (mdp_info.task_runner) {
// The thread local event buffer must be initialized at this point as it
// registers its own dump provider (for tracing overhead acounting).
@@ -439,7 +451,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() {
}
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698