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

Unified Diff: components/browser_watcher/postmortem_report_collector.h

Issue 2128683002: Collect unclean shutdown debug information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracker
Patch Set: Merge 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_report_collector.h
diff --git a/components/browser_watcher/postmortem_report_collector.h b/components/browser_watcher/postmortem_report_collector.h
new file mode 100644
index 0000000000000000000000000000000000000000..7546961a26589b8034de378c8022e784076583eb
--- /dev/null
+++ b/components/browser_watcher/postmortem_report_collector.h
@@ -0,0 +1,80 @@
+// 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_REPORT_COLLECTOR_H_
+#define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_
+
+#include <stdio.h>
+
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "components/browser_watcher/stability_report.pb.h"
+#include "third_party/crashpad/crashpad/client/crash_report_database.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 and some error logging.
Sigurður Ásgeirsson 2016/08/11 17:44:15 as we discussed earlier today, it'd be better^Weas
manzagop (departed) 2016/08/12 21:23:22 Sgtm. Let's include moving the code and this TODO
+class PostmortemReportCollector {
+ public:
+ // 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,
+ std::unique_ptr<crashpad::CrashReportDatabase> report_database);
+ 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);
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest,
+ GetDebugStateFilePaths);
+ FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectEmptyFile);
+ FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectRandomFile);
+ FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorCollectionTest,
+ CollectSuccess);
+
+ PostmortemReportCollector();
+
+ // Virtual for unittesting.
Sigurður Ásgeirsson 2016/08/11 17:44:15 I do hope there's a test for this method, as it ge
manzagop (departed) 2016/08/12 21:23:22 Well... there is a test! The reason: I was thinki
+ virtual std::vector<base::FilePath> GetDebugStateFilePaths(
+ const std::set<base::FilePath>& excluded_debug_files);
+
+ // Virtual for unittesting.
+ // TODO(manzagop): move this for reuse in live scenario.
+ virtual std::unique_ptr<StabilityReport> Collect(
+ const base::FilePath& debug_state_file);
+
+ virtual bool WriteReportToMinidump(const StabilityReport& report,
+ const crashpad::UUID& client_id,
+ const crashpad::UUID& report_id,
+ FILE* minidump_file);
+
+ base::FilePath debug_state_dir_;
Sigurður Ásgeirsson 2016/08/11 17:44:15 there doesn't seem to be any benefit to the debug_
manzagop (departed) 2016/08/12 21:23:22 Agreed, removed. The class is now an empty husk. I
+ base::FilePath::StringType debug_file_pattern_;
+ std::unique_ptr<crashpad::CrashReportDatabase> report_database_;
+
+ DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector);
+};
+
+} // namespace browser_watcher
+
+#endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698