Chromium Code Reviews| Index: unclean_shutdown_collector.cc |
| diff --git a/unclean_shutdown_collector.cc b/unclean_shutdown_collector.cc |
| index bb2dd7a862ee50597868cf5ecfbf8cab6caa2dbe..3f17c22a7181cc9eb34e42ef377c7c08f1e07bfe 100644 |
| --- a/unclean_shutdown_collector.cc |
| +++ b/unclean_shutdown_collector.cc |
| @@ -5,12 +5,44 @@ |
| #include "crash-reporter/unclean_shutdown_collector.h" |
| #include "base/file_util.h" |
| +#include "base/time.h" |
|
kmixter1
2010/11/18 02:58:19
abc order
|
| #include "base/logging.h" |
| #include "crash-reporter/system_logging.h" |
| static const char kUncleanShutdownFile[] = |
| "/var/lib/crash_reporter/pending_clean_shutdown"; |
| +// Files created by power manager used for crash reporting |
|
kmixter1
2010/11/18 02:58:19
Periods at end of comments please.
|
| +#define TRACE_PATH "/var/lib/power_manager" |
| +static const char kPowerdTracePath[] = TRACE_PATH; |
| +// File with timestamp of last suspend |
| +static const char kPowerdSuspendFile[] = TRACE_PATH "/powerd_suspending"; |
|
kmixter1
2010/11/18 02:58:19
Just make this be the filename, make kPowerdTraceP
kmixter1
2010/11/18 02:58:19
I suggest making this be the filename, make kPower
|
| +// File with timestamp of last resume |
| +static const char kPowerdResumeFile[] = TRACE_PATH "/powerd_resuming"; |
| +// Presence of this file indicates that the battery is critically low |
| +static const char kPowerdLowBatteryFile[] = TRACE_PATH "/powerd_low_battery"; |
| + |
| +bool UncleanShutdownCollector::ReadModificationTime(const char *file_string) |
| +{ |
| + FilePath file_path(file_string); |
| + file_util::FileInfo file_info; |
| + base::Time::Exploded timestamp; |
| + // Initialize timestamp fields to prevent warnings during print |
| + timestamp.hour = -1; |
| + timestamp.minute = -1; |
| + timestamp.second = -1; |
| + // Log the file modification time if it exists |
| + if (file_util::PathExists(file_path)) { |
| + if (!GetFileInfo(file_path, &file_info)) |
| + return false; |
| + file_info.last_modified.LocalExplode(×tamp); |
| + logger_->LogInfo("File %s modified at %02d:%02d:%02d", file_string, |
| + timestamp.hour, timestamp.minute, timestamp.second); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| UncleanShutdownCollector::UncleanShutdownCollector() |
| : unclean_shutdown_file_(kUncleanShutdownFile) { |
| } |
| @@ -45,6 +77,14 @@ bool UncleanShutdownCollector::Collect() { |
| logger_->LogWarning("Last shutdown was not clean"); |
| DeleteUncleanShutdownFile(); |
| + // Check for failed suspend |
| + logger_->LogInfo("Checking for Power Daemon files"); |
| + ReadModificationTime(kPowerdSuspendFile); |
|
kmixter1
2010/11/18 02:58:19
I really would like to see the logic of figuring o
|
| + ReadModificationTime(kPowerdResumeFile); |
| + ReadModificationTime(kPowerdLowBatteryFile); |
| + file_util::Delete(FilePath(kPowerdSuspendFile), false); |
| + file_util::Delete(FilePath(kPowerdResumeFile), false); |
| + file_util::Delete(FilePath(kPowerdLowBatteryFile), false); |
| if (is_feedback_allowed_function_()) { |
| count_crash_function_(); |
| } |
| @@ -53,5 +93,8 @@ bool UncleanShutdownCollector::Collect() { |
| bool UncleanShutdownCollector::Disable() { |
| logger_->LogInfo("Clean shutdown signalled"); |
| + file_util::Delete(FilePath(kPowerdSuspendFile), false); |
| + file_util::Delete(FilePath(kPowerdResumeFile), false); |
| + file_util::Delete(FilePath(kPowerdLowBatteryFile), false); |
| return DeleteUncleanShutdownFile(); |
| } |