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

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: ABC order, ASSERT_EQ order 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
« no previous file with comments | « unclean_shutdown_collector.h ('k') | unclean_shutdown_collector_test.cc » ('j') | 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..1e1c7842a66de998c5f8c6fab50a6dc485b143c2 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";
+// Presence of this file indicates that the system was suspended
+static const char kPowerdSuspended[] = "powerd_suspended";
+// Presence of this file indicates that the battery was critically low.
+static const char kPowerdLowBattery[] = "powerd_low_battery";
+
UncleanShutdownCollector::UncleanShutdownCollector()
- : unclean_shutdown_file_(kUncleanShutdownFile) {
+ : unclean_shutdown_file_(kUncleanShutdownFile),
+ powerd_trace_path_(kPowerdTracePath),
+ powerd_suspended_file_(powerd_trace_path_.Append(kPowerdSuspended)),
+ powerd_low_battery_file_(powerd_trace_path_.Append(kPowerdLowBattery)) {
}
UncleanShutdownCollector::~UncleanShutdownCollector() {
@@ -28,12 +38,15 @@ bool UncleanShutdownCollector::Enable() {
return true;
}
-bool UncleanShutdownCollector::DeleteUncleanShutdownFile() {
+bool UncleanShutdownCollector::DeleteUncleanShutdownFiles() {
if (!file_util::Delete(FilePath(unclean_shutdown_file_), false)) {
logger_->LogError("Failed to delete unclean shutdown file %s",
unclean_shutdown_file_);
return false;
}
+ // Delete power manager trace files if they exist.
+ file_util::Delete(powerd_suspended_file_, false);
+ file_util::Delete(powerd_low_battery_file_, false);
return true;
}
@@ -43,7 +56,11 @@ bool UncleanShutdownCollector::Collect() {
return false;
}
logger_->LogWarning("Last shutdown was not clean");
- DeleteUncleanShutdownFile();
+ if (DeadBatteryCausedUncleanShutdown()) {
+ DeleteUncleanShutdownFiles();
+ return false;
+ }
+ DeleteUncleanShutdownFiles();
if (is_feedback_allowed_function_()) {
count_crash_function_();
@@ -53,5 +70,24 @@ bool UncleanShutdownCollector::Collect() {
bool UncleanShutdownCollector::Disable() {
logger_->LogInfo("Clean shutdown signalled");
- return DeleteUncleanShutdownFile();
+ return DeleteUncleanShutdownFiles();
+}
+
+bool UncleanShutdownCollector::DeadBatteryCausedUncleanShutdown()
+{
+ // Check for case of battery running out while suspended.
+ if (file_util::PathExists(powerd_suspended_file_)) {
+ logger_->LogInfo("Unclean shutdown occurred while suspended. Not counting "
+ "toward unclean shutdown statistic.");
+ 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 running with battery "
+ "critically low. Not counting toward unclean shutdown "
+ "statistic.");
+ return true;
+ }
+ return false;
}
« no previous file with comments | « unclean_shutdown_collector.h ('k') | unclean_shutdown_collector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698