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

Unified Diff: unclean_shutdown_collector.cc

Issue 3179006: Collect and send kernel crash diagnostics (Closed) Base URL: ssh://git@chromiumos-git//crash-reporter.git
Patch Set: Respond to reviews Created 10 years, 4 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') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..bb2dd7a862ee50597868cf5ecfbf8cab6caa2dbe
--- /dev/null
+++ b/unclean_shutdown_collector.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "crash-reporter/unclean_shutdown_collector.h"
+
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "crash-reporter/system_logging.h"
+
+static const char kUncleanShutdownFile[] =
+ "/var/lib/crash_reporter/pending_clean_shutdown";
+
+UncleanShutdownCollector::UncleanShutdownCollector()
+ : unclean_shutdown_file_(kUncleanShutdownFile) {
+}
+
+UncleanShutdownCollector::~UncleanShutdownCollector() {
+}
+
+bool UncleanShutdownCollector::Enable() {
+ FilePath file_path(unclean_shutdown_file_);
+ file_util::CreateDirectory(file_path.DirName());
+ if (file_util::WriteFile(file_path, "", 0) != 0) {
+ logger_->LogError("Unable to create shutdown check file");
+ return false;
+ }
+ return true;
+}
+
+bool UncleanShutdownCollector::DeleteUncleanShutdownFile() {
+ if (!file_util::Delete(FilePath(unclean_shutdown_file_), false)) {
+ logger_->LogError("Failed to delete unclean shutdown file %s",
+ unclean_shutdown_file_);
+ return false;
+ }
+ return true;
+}
+
+bool UncleanShutdownCollector::Collect() {
+ FilePath unclean_file_path(unclean_shutdown_file_);
+ if (!file_util::PathExists(unclean_file_path)) {
+ return false;
+ }
+ logger_->LogWarning("Last shutdown was not clean");
+ DeleteUncleanShutdownFile();
+
+ if (is_feedback_allowed_function_()) {
+ count_crash_function_();
+ }
+ return true;
+}
+
+bool UncleanShutdownCollector::Disable() {
+ logger_->LogInfo("Clean shutdown signalled");
+ return DeleteUncleanShutdownFile();
+}
« 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