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

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

Issue 2497833002: support multiple log message handlers in base/logging.h (Closed)
Patch Set: 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
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | net/tools/stress_cache/stress_cache.cc » ('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 252df3da7c5b61499a37109909f392706885147d..3effb5d48f103612e3be6c4e16d0cabb2da31b91 100644
--- a/ios/chrome/browser/crash_report/breakpad_helper.mm
+++ b/ios/chrome/browser/crash_report/breakpad_helper.mm
@@ -78,11 +78,10 @@ void ClearCrashKeyValueImpl(const base::StringPiece& key) {
RemoveReportParameter(base::SysUTF8ToNSString(key.as_string()));
}
-// Callback for logging::SetLogMessageHandler
+// Callback for logging::AddLogMessageHandler
bool FatalMessageHandler(int severity,
- const char* file,
+ const std::string& file,
int line,
- size_t message_start,
const std::string& str) {
// Do not handle non-FATAL.
if (severity != logging::LOG_FATAL)
@@ -99,15 +98,16 @@ bool FatalMessageHandler(int severity,
base::AutoReset<bool> guard(&guarded, true);
// Only log last path component. This matches logging.cc.
- if (file) {
- const char* slash = strrchr(file, '/');
- if (slash)
- file = slash + 1;
- }
+ size_t last_slash = file.rfind('/');
+ if (last_slash == file.npos)
+ last_slash = 0;
+ else
+ last_slash++;
NSString* fatal_key = @"LOG_FATAL";
- NSString* fatal_value = [NSString
- stringWithFormat:@"%s:%d: %s", file, line, str.c_str() + message_start];
+ NSString* fatal_value =
+ [NSString stringWithFormat:@"%s:%d: %s", file.substr(last_slash).c_str(),
+ line, str.c_str()];
AddReportParameter(fatal_key, fatal_value, true);
// Rather than including the code to force the crash here, allow the
@@ -130,7 +130,7 @@ void Start(const std::string& channel_name) {
[[BreakpadController sharedInstance] start:YES];
base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueImpl,
&ClearCrashKeyValueImpl);
- logging::SetLogMessageHandler(&FatalMessageHandler);
+ logging::AddLogMessageHandler(&FatalMessageHandler);
g_crash_reporter_enabled = true;
// Register channel information.
if (channel_name.length()) {
« no previous file with comments | « content/gpu/gpu_main.cc ('k') | net/tools/stress_cache/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698