Chromium Code Reviews| 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..1770f5aa902facf170a60c5d7e0721571977e3aa |
| --- /dev/null |
| +++ b/components/browser_watcher/postmortem_report_collector.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_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. |
| +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, |
|
Sigurður Ásgeirsson
2016/09/14 18:04:31
the docs look outdated.
manzagop (departed)
2016/09/15 15:07:38
Removed. Done.
|
| + // |delegate| will be used for reporting. |
| + PostmortemReportCollector(); |
| + virtual ~PostmortemReportCollector() = default; |
| + |
| + // Inspects stability debug information files in |debug_dir| using |
| + // |debug_file_pattern| and |excluded_debug_files|. Collects reports about |
| + // unclean shutdowns and submits them for upload to |report_database|. Deletes |
| + // the stability debug information files. |
|
Sigurður Ásgeirsson
2016/09/14 18:04:31
what does it return?
manzagop (departed)
2016/09/15 15:07:38
Done.
|
| + int CollectAndSubmitForUpload( |
| + const base::FilePath& debug_info_dir, |
| + const base::FilePath::StringType& debug_file_pattern, |
| + const std::set<base::FilePath>& excluded_debug_files, |
| + crashpad::CrashReportDatabase* report_database); |
| + |
| + private: |
|
Sigurður Ásgeirsson
2016/09/14 18:04:31
is this the recommended way to do things? Another
manzagop (departed)
2016/09/15 15:07:38
Dunno. I started with what you suggest, but change
Sigurður Ásgeirsson
2016/09/15 18:44:10
I have no strong preference.
|
| + FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, |
| + GetDebugStateFilePaths); |
| + FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectEmptyFile); |
| + FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectRandomFile); |
| + FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorCollectionTest, |
| + CollectSuccess); |
| + |
| + // Virtual for unittesting. |
| + virtual std::vector<base::FilePath> GetDebugStateFilePaths( |
| + const base::FilePath& debug_info_dir, |
| + const base::FilePath::StringType& debug_file_pattern, |
| + 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, |
| + base::PlatformFile minidump_file); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector); |
| +}; |
| + |
| +} // namespace browser_watcher |
| + |
| +#endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ |