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

Unified Diff: components/crash/content/app/crashpad.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 11 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 | « components/crash/content/app/breakpad_mac.mm ('k') | components/proximity_auth/logging/logging_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/crashpad.cc
diff --git a/components/crash/content/app/crashpad.cc b/components/crash/content/app/crashpad.cc
index a0eabba349246f0540a88cf0a5b260f1b3e65c04..494131acb3a54d93e61660a3cc026cb24f449990 100644
--- a/components/crash/content/app/crashpad.cc
+++ b/components/crash/content/app/crashpad.cc
@@ -52,14 +52,22 @@ void ClearCrashKey(const base::StringPiece& key) {
g_simple_string_dictionary->RemoveKey(key.data());
}
-bool LogMessageHandler(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& string) {
+class LogMessageListener : logging::LogMessageListener {
+ void OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& string) override;
+};
+
+void LogMessageListener::OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& string) {
// Only handle FATAL.
if (severity != logging::LOG_FATAL) {
- return false;
+ return;
}
// In case of an out-of-memory condition, this code could be reentered when
@@ -68,7 +76,7 @@ bool LogMessageHandler(int severity,
// should work.
static bool guarded = false;
if (guarded) {
- return false;
+ return;
}
base::AutoReset<bool> guard(&guarded, true);
@@ -87,7 +95,6 @@ bool LogMessageHandler(int severity,
// Rather than including the code to force the crash here, allow the caller to
// do it.
- return false;
}
void DumpWithoutCrashing() {
@@ -164,7 +171,8 @@ void InitializeCrashpadImpl(bool initial_client,
SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId()));
#endif
- logging::SetLogMessageHandler(LogMessageHandler);
+ // Intentionally leak the listener.
+ new LogMessageListener();
// If clients called CRASHPAD_SIMULATE_CRASH() instead of
// base::debug::DumpWithoutCrashing(), these dumps would appear as crashes in
« no previous file with comments | « components/crash/content/app/breakpad_mac.mm ('k') | components/proximity_auth/logging/logging_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698