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_REPORT_COLLECTOR_H_ | |
9 #define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ | |
10 | |
11 #include <stdio.h> | |
12 | |
13 #include <memory> | |
14 #include <set> | |
15 #include <vector> | |
16 | |
17 #include "base/files/file.h" | |
18 #include "base/files/file_path.h" | |
19 #include "base/gtest_prod_util.h" | |
20 #include "base/macros.h" | |
21 #include "components/browser_watcher/stability_report.pb.h" | |
22 #include "third_party/crashpad/crashpad/client/crash_report_database.h" | |
23 | |
24 namespace browser_watcher { | |
25 | |
26 // Collects unclean shutdown information, builds reports out of it and submits | |
27 // the reports for upload to a delegate. | |
28 // TODO(manzagop): throttling, graceful handling of accumulating data. | |
29 // TODO(manzagop): UMA metrics and some error logging. | |
30 class PostmortemReportCollector { | |
31 public: | |
32 // Creates a postmortem report collector that will look for unclean shutdown | |
33 // 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.
| |
34 // |delegate| will be used for reporting. | |
35 PostmortemReportCollector(); | |
36 virtual ~PostmortemReportCollector() = default; | |
37 | |
38 // Inspects stability debug information files in |debug_dir| using | |
39 // |debug_file_pattern| and |excluded_debug_files|. Collects reports about | |
40 // unclean shutdowns and submits them for upload to |report_database|. Deletes | |
41 // 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.
| |
42 int CollectAndSubmitForUpload( | |
43 const base::FilePath& debug_info_dir, | |
44 const base::FilePath::StringType& debug_file_pattern, | |
45 const std::set<base::FilePath>& excluded_debug_files, | |
46 crashpad::CrashReportDatabase* report_database); | |
47 | |
48 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.
| |
49 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, | |
50 GetDebugStateFilePaths); | |
51 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectEmptyFile); | |
52 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectRandomFile); | |
53 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorCollectionTest, | |
54 CollectSuccess); | |
55 | |
56 // Virtual for unittesting. | |
57 virtual std::vector<base::FilePath> GetDebugStateFilePaths( | |
58 const base::FilePath& debug_info_dir, | |
59 const base::FilePath::StringType& debug_file_pattern, | |
60 const std::set<base::FilePath>& excluded_debug_files); | |
61 | |
62 // Virtual for unittesting. | |
63 // TODO(manzagop): move this for reuse in live scenario. | |
64 virtual std::unique_ptr<StabilityReport> Collect( | |
65 const base::FilePath& debug_state_file); | |
66 | |
67 virtual bool WriteReportToMinidump(const StabilityReport& report, | |
68 const crashpad::UUID& client_id, | |
69 const crashpad::UUID& report_id, | |
70 base::PlatformFile minidump_file); | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector); | |
73 }; | |
74 | |
75 } // namespace browser_watcher | |
76 | |
77 #endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ | |
OLD | NEW |