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

Unified Diff: components/browser_watcher/postmortem.h

Issue 2128683002: Collect unclean shutdown debug information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracker
Patch Set: Minimal collection to proto Created 4 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
Index: components/browser_watcher/postmortem.h
diff --git a/components/browser_watcher/postmortem.h b/components/browser_watcher/postmortem.h
new file mode 100644
index 0000000000000000000000000000000000000000..473e777b6c24d2b39c08b1f7399e6a7b8b6b91d9
--- /dev/null
+++ b/components/browser_watcher/postmortem.h
@@ -0,0 +1,77 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Following an unclean shutdown, a stability report can be collected and
+// submitted for upload to a reporter.
+
+#ifndef COMPONENTS_BROWSER_WATCHER_POSTMORTEM_H_
scottmg 2016/08/03 22:47:06 postmortem_report_collector.h?
manzagop (departed) 2016/08/10 15:59:51 Done. Ah sorry! I should have left the renaming
+#define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_H_
+
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "components/browser_watcher/stability_report.pb.h"
+
+namespace browser_watcher {
+
+// Collects unclean shutdown information, builds reports out of it and submits
+// the reports for upload to a delegate.
+// TODO(manzagop): throttling, graceful handling of accumulating data.
+// TODO(manzagop): UMA metrics.
+class PostmortemReportCollector {
+ public:
+ // Handles reporting the stability reports, including validating user consent,
+ // assigning a report id and potential throttling. Takes ownership of the
+ // report files.
+ class ReporterDelegate {
+ public:
+ virtual ~ReporterDelegate() = default;
+ // TODO(manzagop): specific crash keys are desirable. Work it out.
+ virtual void SubmitReportForUpload(const base::FilePath& minidump) = 0;
scottmg 2016/08/03 22:47:06 Because of the crash report database API, you migh
manzagop (departed) 2016/08/10 15:59:51 I changed a few things and I take a dependency on
+ };
+
+ // Creates a postmortem report collector that will look for unclean shutdown
+ // data in |debug_dir| using |debug_file_pattern|. If data is found,
+ // |delegate| will be used for reporting.
+ PostmortemReportCollector(
+ const base::FilePath& debug_dir,
+ const base::FilePath::StringType& debug_file_pattern,
+ ReporterDelegate* delegate);
+ virtual ~PostmortemReportCollector() = default;
+
+ // Collects reports about unclean shutdowns and submits them for upload.
+ // |excluded_debug_files| is a set of files to exclude, such as files
+ // pertaining to a running instance.
+ void CollectAndSubmitForUpload(
+ const std::set<base::FilePath>& excluded_debug_files);
+
+ protected:
+ // For unittesting.
scottmg 2016/08/03 22:47:06 Maybe private and friend the test.
manzagop (departed) 2016/08/10 15:59:51 Done.
+ PostmortemReportCollector();
+
+ // Virtual and protected for unittesting.
+ virtual std::vector<base::FilePath> GetDebugStateFilePaths(
+ const std::set<base::FilePath>& excluded_debug_files);
+
+ // TODO(manzagop): move this for reuse in live scenario.
+ virtual std::unique_ptr<StabilityReport> Collect(
+ const base::FilePath& debug_state_file);
+
+ virtual bool CreateReport(const StabilityReport& report,
+ const base::FilePath& minidump_path);
+
+ private:
+ base::FilePath debug_state_dir_;
+ base::FilePath::StringType debug_file_pattern_;
+ ReporterDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector);
+};
+
+} // namespace browser_watcher
+
+#endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_H_

Powered by Google App Engine
This is Rietveld 408576698