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

Unified Diff: unclean_shutdown_collector.cc

Issue 3644007: Crash reporter: collect suspend and resume info from power manager (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Reduced to two files and w/o reading timestamps Created 10 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
« unclean_shutdown_collector.h ('K') | « unclean_shutdown_collector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unclean_shutdown_collector.cc
diff --git a/unclean_shutdown_collector.cc b/unclean_shutdown_collector.cc
index bb2dd7a862ee50597868cf5ecfbf8cab6caa2dbe..fcac84586b9eb652fdacdd8dbd3cb552f90eac1b 100644
--- a/unclean_shutdown_collector.cc
+++ b/unclean_shutdown_collector.cc
@@ -11,8 +11,18 @@
static const char kUncleanShutdownFile[] =
"/var/lib/crash_reporter/pending_clean_shutdown";
+// Files created by power manager used for crash reporting.
+static const char kPowerdTracePath[] = "/var/lib/power_manager";
+// File with timestamp of last suspend.
+static const char kPowerdSuspended[] = "powerd_suspended";
+// Presence of this file indicates that the battery is critically low.
+static const char kPowerdLowBattery[] = "powerd_low_battery";
+
UncleanShutdownCollector::UncleanShutdownCollector()
- : unclean_shutdown_file_(kUncleanShutdownFile) {
+ : unclean_shutdown_file_(kUncleanShutdownFile),
+ powerd_trace_path_(kPowerdTracePath),
+ powerd_suspend_file_(powerd_trace_path_.Append(kPowerdSuspended)),
+ powerd_low_battery_file_(powerd_trace_path_.Append(kPowerdLowBattery)) {
}
UncleanShutdownCollector::~UncleanShutdownCollector() {
@@ -45,6 +55,10 @@ bool UncleanShutdownCollector::Collect() {
logger_->LogWarning("Last shutdown was not clean");
DeleteUncleanShutdownFile();
+ CheckForDeadBatteryUncleanShutdown();
+ file_util::Delete(powerd_suspend_file_, false);
kmixter1 2010/11/19 23:43:27 Still would be nice to factor this out. How about
+ file_util::Delete(powerd_low_battery_file_, false);
+
if (is_feedback_allowed_function_()) {
count_crash_function_();
}
@@ -53,5 +67,25 @@ bool UncleanShutdownCollector::Collect() {
bool UncleanShutdownCollector::Disable() {
logger_->LogInfo("Clean shutdown signalled");
+ file_util::Delete(powerd_suspend_file_, false);
+ file_util::Delete(powerd_low_battery_file_, false);
return DeleteUncleanShutdownFile();
}
+
+bool UncleanShutdownCollector::CheckForDeadBatteryUncleanShutdown()
+{
+ // Check for case of battery running out while suspended.
+ if (file_util::PathExists(powerd_suspend_file_)) {
+ logger_->LogInfo("Unclean shutdown occurred while suspended. The battery "
+ "probably ran out.");
+ return true;
+ }
+ // Check for case of battery running out after resuming from a low-battery
+ // suspend.
+ if (file_util::PathExists(powerd_low_battery_file_)) {
+ logger_->LogInfo("Unclean shutdown occurred while resumed after battery "
kmixter1 2010/11/19 23:43:27 how about "while running with critically low batte
+ "was critically low. The battery probably ran out.");
+ return true;
+ }
+ return false;
+}
« unclean_shutdown_collector.h ('K') | « unclean_shutdown_collector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698