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

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: 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 | « content/gpu/gpu_main.cc ('k') | net/test/gtest_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4ae4326a950f17503efd274a8578d9e974dc80fd..aa9b0714c18602b1399c80458567a8b5bd159f64 100644
--- a/ios/chrome/browser/crash_report/breakpad_helper.mm
+++ b/ios/chrome/browser/crash_report/breakpad_helper.mm
@@ -82,15 +82,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
@@ -98,7 +105,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);
@@ -116,7 +123,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
@@ -134,7 +140,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()) {
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | net/test/gtest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698