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

Side by Side Diff: crash_reporter.cc

Issue 2716010: Broadcast a D-Bus message whenever a user-space process crash happens. (Closed) Base URL: ssh://git@chromiumos-git/crash.git
Patch Set: Be explicit about the unused result status. Created 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "crash/system_logging.h" 10 #include "crash/system_logging.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 static void SignalCleanShutdown() { 70 static void SignalCleanShutdown() {
71 s_system_log.LogInfo("Clean shutdown signalled"); 71 s_system_log.LogInfo("Clean shutdown signalled");
72 file_util::Delete(FilePath(kUncleanShutdownFile), false); 72 file_util::Delete(FilePath(kUncleanShutdownFile), false);
73 } 73 }
74 74
75 static void CountUserCrash() { 75 static void CountUserCrash() {
76 CHECK(IsMetricsCollectionAllowed()); 76 CHECK(IsMetricsCollectionAllowed());
77 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), 77 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram),
78 CRASH_KIND_USER, 78 CRASH_KIND_USER,
79 CRASH_KIND_MAX); 79 CRASH_KIND_MAX);
80
81 // Announce through D-Bus whenever a user crash happens. This is
82 // used by the metrics daemon to log active use time between
83 // crashes.
84 //
85 // This could be done more efficiently by explicit fork/exec or
86 // using a dbus library directly. However, this should run
87 // relatively rarely and longer term we may need to implement a
88 // better way to do this that doesn't rely on D-Bus.
89 int status __attribute__((unused)) =
90 system("/usr/bin/dbus-send --type=signal --system / "
91 "org.chromium.CrashReporter.UserCrash");
80 } 92 }
81 93
82 int main(int argc, char *argv[]) { 94 int main(int argc, char *argv[]) {
83 google::ParseCommandLineFlags(&argc, &argv, true); 95 google::ParseCommandLineFlags(&argc, &argv, true);
84 FilePath my_path(argv[0]); 96 FilePath my_path(argv[0]);
85 file_util::AbsolutePath(&my_path); 97 file_util::AbsolutePath(&my_path);
86 s_metrics_lib.Init(); 98 s_metrics_lib.Init();
87 s_system_log.Initialize(my_path.BaseName().value().c_str()); 99 s_system_log.Initialize(my_path.BaseName().value().c_str());
88 UserCollector user_collector; 100 UserCollector user_collector;
89 user_collector.Initialize(CountUserCrash, 101 user_collector.Initialize(CountUserCrash,
(...skipping 28 matching lines...) Expand all
118 // handling a crash. 130 // handling a crash.
119 if (FLAGS_crash_test) { 131 if (FLAGS_crash_test) {
120 *(char *)0 = 0; 132 *(char *)0 = 0;
121 return 0; 133 return 0;
122 } 134 }
123 135
124 user_collector.HandleCrash(FLAGS_signal, FLAGS_pid, FLAGS_exec); 136 user_collector.HandleCrash(FLAGS_signal, FLAGS_pid, FLAGS_exec);
125 137
126 return 0; 138 return 0;
127 } 139 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698