OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 // | |
5 // Following an unclean shutdown, a stability report can be collected and | |
6 // submitted for upload to a reporter. | |
7 | |
8 #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
| |
9 #define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_H_ | |
10 | |
11 #include <memory> | |
12 #include <set> | |
13 #include <vector> | |
14 | |
15 #include "base/files/file_path.h" | |
16 #include "base/macros.h" | |
17 #include "components/browser_watcher/stability_report.pb.h" | |
18 | |
19 namespace browser_watcher { | |
20 | |
21 // Collects unclean shutdown information, builds reports out of it and submits | |
22 // the reports for upload to a delegate. | |
23 // TODO(manzagop): throttling, graceful handling of accumulating data. | |
24 // TODO(manzagop): UMA metrics. | |
25 class PostmortemReportCollector { | |
26 public: | |
27 // Handles reporting the stability reports, including validating user consent, | |
28 // assigning a report id and potential throttling. Takes ownership of the | |
29 // report files. | |
30 class ReporterDelegate { | |
31 public: | |
32 virtual ~ReporterDelegate() = default; | |
33 // TODO(manzagop): specific crash keys are desirable. Work it out. | |
34 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
| |
35 }; | |
36 | |
37 // Creates a postmortem report collector that will look for unclean shutdown | |
38 // data in |debug_dir| using |debug_file_pattern|. If data is found, | |
39 // |delegate| will be used for reporting. | |
40 PostmortemReportCollector( | |
41 const base::FilePath& debug_dir, | |
42 const base::FilePath::StringType& debug_file_pattern, | |
43 ReporterDelegate* delegate); | |
44 virtual ~PostmortemReportCollector() = default; | |
45 | |
46 // Collects reports about unclean shutdowns and submits them for upload. | |
47 // |excluded_debug_files| is a set of files to exclude, such as files | |
48 // pertaining to a running instance. | |
49 void CollectAndSubmitForUpload( | |
50 const std::set<base::FilePath>& excluded_debug_files); | |
51 | |
52 protected: | |
53 // For unittesting. | |
scottmg
2016/08/03 22:47:06
Maybe private and friend the test.
manzagop (departed)
2016/08/10 15:59:51
Done.
| |
54 PostmortemReportCollector(); | |
55 | |
56 // Virtual and protected for unittesting. | |
57 virtual std::vector<base::FilePath> GetDebugStateFilePaths( | |
58 const std::set<base::FilePath>& excluded_debug_files); | |
59 | |
60 // TODO(manzagop): move this for reuse in live scenario. | |
61 virtual std::unique_ptr<StabilityReport> Collect( | |
62 const base::FilePath& debug_state_file); | |
63 | |
64 virtual bool CreateReport(const StabilityReport& report, | |
65 const base::FilePath& minidump_path); | |
66 | |
67 private: | |
68 base::FilePath debug_state_dir_; | |
69 base::FilePath::StringType debug_file_pattern_; | |
70 ReporterDelegate* delegate_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector); | |
73 }; | |
74 | |
75 } // namespace browser_watcher | |
76 | |
77 #endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_H_ | |
OLD | NEW |