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

Unified Diff: ios/chrome/browser/crash_report/breakpad_helper.mm

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 1 month 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
Index: ios/chrome/browser/crash_report/breakpad_helper.mm
diff --git a/ios/chrome/browser/crash_report/breakpad_helper.mm b/ios/chrome/browser/crash_report/breakpad_helper.mm
index 252df3da7c5b61499a37109909f392706885147d..faae91f51b7bf8b0326e9988a3f815f12e570f6a 100644
--- a/ios/chrome/browser/crash_report/breakpad_helper.mm
+++ b/ios/chrome/browser/crash_report/breakpad_helper.mm
@@ -78,15 +78,22 @@ void ClearCrashKeyValueImpl(const base::StringPiece& key) {
RemoveReportParameter(base::SysUTF8ToNSString(key.as_string()));
}
-// Callback for logging::SetLogMessageHandler
-bool FatalMessageHandler(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& str) {
+class FatalMessageListener : logging::LogMessageListener {
+ void OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) override;
+};
+
+void FatalMessageListener::OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
// Do not handle non-FATAL.
if (severity != logging::LOG_FATAL)
- return false;
+ return;
// In case of OOM condition, this code could be reentered when
// constructing and storing the key. Using a static is not
@@ -94,7 +101,7 @@ bool FatalMessageHandler(int severity,
// fatal crash at the same time, this should work.
static bool guarded = false;
if (guarded)
- return false;
+ return;
base::AutoReset<bool> guard(&guarded, true);
@@ -112,7 +119,6 @@ bool FatalMessageHandler(int severity,
// Rather than including the code to force the crash here, allow the
// caller to do it.
- return false;
}
// Caches the uploading flag in NSUserDefaults, so that we can access the value
@@ -130,7 +136,10 @@ void Start(const std::string& channel_name) {
[[BreakpadController sharedInstance] start:YES];
base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueImpl,
&ClearCrashKeyValueImpl);
- logging::SetLogMessageHandler(&FatalMessageHandler);
+ // Intentionally leak the listener.
+ auto* listener = new FatalMessageListener();
+ CHECK(listener);
+
g_crash_reporter_enabled = true;
// Register channel information.
if (channel_name.length()) {

Powered by Google App Engine
This is Rietveld 408576698