crash: Remove references to low-battery state file.

Remove references to the low-battery state file formerly
written by powerd. The system shuts down immediately when it
enters the low-battery state.

BUG=chromium:259189
TEST=ran unit tests

Change-Id: I2122210b448af58fb4ecac2c234b9faa9d231e2b
Reviewed-on: https://gerrit.chromium.org/gerrit/62578
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
diff --git a/crash_reporter/unclean_shutdown_collector.cc b/crash_reporter/unclean_shutdown_collector.cc
index b1462ad..14cc8f4 100644
--- a/crash_reporter/unclean_shutdown_collector.cc
+++ b/crash_reporter/unclean_shutdown_collector.cc
@@ -14,16 +14,13 @@
 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";
 
 using base::FilePath;
 
 UncleanShutdownCollector::UncleanShutdownCollector()
     : 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)) {
+      powerd_suspended_file_(powerd_trace_path_.Append(kPowerdSuspended)) {
 }
 
 UncleanShutdownCollector::~UncleanShutdownCollector() {
@@ -45,9 +42,8 @@
                << unclean_shutdown_file_;
     return false;
   }
-  // Delete power manager trace files if they exist.
+  // Delete power manager state file if it exists.
   file_util::Delete(powerd_suspended_file_, false);
-  file_util::Delete(powerd_low_battery_file_, false);
   return true;
 }
 
@@ -74,21 +70,12 @@
   return DeleteUncleanShutdownFiles();
 }
 
-bool UncleanShutdownCollector::DeadBatteryCausedUncleanShutdown()
-{
+bool UncleanShutdownCollector::DeadBatteryCausedUncleanShutdown() {
   // Check for case of battery running out while suspended.
   if (file_util::PathExists(powerd_suspended_file_)) {
     LOG(INFO) << "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_)) {
-    LOG(INFO) << "Unclean shutdown occurred while running with battery "
-              << "critically low.  Not counting toward unclean shutdown "
-              << "statistic.";
-    return true;
-  }
   return false;
 }
diff --git a/crash_reporter/unclean_shutdown_collector.h b/crash_reporter/unclean_shutdown_collector.h
index 37eb4df..7a5b669 100644
--- a/crash_reporter/unclean_shutdown_collector.h
+++ b/crash_reporter/unclean_shutdown_collector.h
@@ -30,7 +30,6 @@
  private:
   friend class UncleanShutdownCollectorTest;
   FRIEND_TEST(UncleanShutdownCollectorTest, EnableCannotWrite);
-  FRIEND_TEST(UncleanShutdownCollectorTest, CollectDeadBatteryRunningLow);
   FRIEND_TEST(UncleanShutdownCollectorTest, CollectDeadBatterySuspended);
 
   bool DeleteUncleanShutdownFiles();
@@ -42,7 +41,6 @@
   const char *unclean_shutdown_file_;
   base::FilePath powerd_trace_path_;
   base::FilePath powerd_suspended_file_;
-  base::FilePath powerd_low_battery_file_;
 };
 
 #endif  // _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_
diff --git a/crash_reporter/unclean_shutdown_collector_test.cc b/crash_reporter/unclean_shutdown_collector_test.cc
index 1bb0c94..21e2aaa 100644
--- a/crash_reporter/unclean_shutdown_collector_test.cc
+++ b/crash_reporter/unclean_shutdown_collector_test.cc
@@ -16,7 +16,6 @@
 static bool s_metrics = true;
 
 static const char kTestDirectory[] = "test";
-static const char kTestLowBattery[] = "test/low_battery";
 static const char kTestSuspended[] = "test/suspended";
 static const char kTestUnclean[] = "test/unclean";
 
@@ -40,9 +39,8 @@
     test_unclean_ = FilePath(kTestUnclean);
     collector_.unclean_shutdown_file_ = kTestUnclean;
     file_util::Delete(test_unclean_, true);
-    // Set up alternate power manager tracing files as well
+    // Set up an alternate power manager state file as well
     collector_.powerd_suspended_file_ = FilePath(kTestSuspended);
-    collector_.powerd_low_battery_file_ = FilePath(kTestLowBattery);
     chromeos::ClearLog();
   }
  protected:
@@ -87,18 +85,6 @@
   ASSERT_EQ(0, s_crashes);
 }
 
-TEST_F(UncleanShutdownCollectorTest, CollectDeadBatteryRunningLow) {
-  ASSERT_TRUE(collector_.Enable());
-  ASSERT_TRUE(file_util::PathExists(test_unclean_));
-  file_util::WriteFile(collector_.powerd_low_battery_file_, "", 0);
-  ASSERT_FALSE(collector_.Collect());
-  ASSERT_FALSE(file_util::PathExists(test_unclean_));
-  ASSERT_FALSE(file_util::PathExists(collector_.powerd_low_battery_file_));
-  ASSERT_EQ(0, s_crashes);
-  ASSERT_TRUE(FindLog(
-      "Unclean shutdown occurred while running with battery critically low."));
-}
-
 TEST_F(UncleanShutdownCollectorTest, CollectDeadBatterySuspended) {
   ASSERT_TRUE(collector_.Enable());
   ASSERT_TRUE(file_util::PathExists(test_unclean_));