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

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: Cleanup of old files Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 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..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(&timestamp);
+ 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();
}
« no previous file with comments | « unclean_shutdown_collector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698