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

Side by Side Diff: components/browser_watcher/postmortem_report_collector.h

Issue 2339193003: A collector for postmortem reports (Closed)
Patch Set: Address first round of comments Created 4 years, 3 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 unified diff | Download patch
OLDNEW
(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 and creates Crashpad minidumps.
27 // TODO(manzagop): throttling, graceful handling of accumulating data.
28 // TODO(manzagop): UMA metrics and some error logging.
29 class PostmortemReportCollector {
30 public:
31 PostmortemReportCollector() = default;
32 virtual ~PostmortemReportCollector() = default;
33
34 // Collects postmortem stability reports from files found in |debug_info_dir|,
35 // relying on |debug_file_pattern| and |excluded_debug_files|. Reports are
36 // then wrapped in Crashpad reports, manufactured via |report_database|.
37 // Returns the number of actual postmortem reports found, irrespective of
38 // whether they were successfully converted to a Crashpad report (e.g. files
39 // that cannot be deleted will be counted, each time, even though the crash
40 // report will not be successfully produced).
41 int CollectAndSubmitForUpload(
42 const base::FilePath& debug_info_dir,
43 const base::FilePath::StringType& debug_file_pattern,
44 const std::set<base::FilePath>& excluded_debug_files,
45 crashpad::CrashReportDatabase* report_database);
46
47 private:
48 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest,
49 GetDebugStateFilePaths);
50 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectEmptyFile);
51 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorTest, CollectRandomFile);
52 FRIEND_TEST_ALL_PREFIXES(PostmortemReportCollectorCollectionTest,
53 CollectSuccess);
54
55 // Virtual for unittesting.
56 virtual std::vector<base::FilePath> GetDebugStateFilePaths(
57 const base::FilePath& debug_info_dir,
58 const base::FilePath::StringType& debug_file_pattern,
59 const std::set<base::FilePath>& excluded_debug_files);
60
61 // Virtual for unittesting.
62 // TODO(manzagop): move this for reuse in live scenario.
63 virtual std::unique_ptr<StabilityReport> Collect(
64 const base::FilePath& debug_state_file);
65
66 virtual bool WriteReportToMinidump(const StabilityReport& report,
67 const crashpad::UUID& client_id,
68 const crashpad::UUID& report_id,
69 base::PlatformFile minidump_file);
70
71 DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector);
72 };
73
74 } // namespace browser_watcher
75
76 #endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698