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

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

Issue 2715903003: Bound the impact of system instability on chrome instability. (Closed)
Patch Set: Address siggi@ comments Created 3 years, 9 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Following an unclean shutdown, a stability report can be collected and 5 // Following an unclean shutdown, a stability report can be collected and
6 // submitted for upload to a reporter. 6 // submitted for upload to a reporter.
7 7
8 #ifndef COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ 8 #ifndef COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_
9 #define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ 9 #define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_
10 10
11 #include <stdio.h> 11 #include <stdio.h>
12 12
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/debug/activity_analyzer.h" 18 #include "base/debug/activity_analyzer.h"
19 #include "base/files/file.h" 19 #include "base/files/file.h"
20 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
21 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
24 #include "components/browser_watcher/stability_report.pb.h" 24 #include "components/browser_watcher/stability_report.pb.h"
25 #include "components/browser_watcher/system_session_analyzer_win.h"
25 #include "third_party/crashpad/crashpad/client/crash_report_database.h" 26 #include "third_party/crashpad/crashpad/client/crash_report_database.h"
26 27
27 namespace browser_watcher { 28 namespace browser_watcher {
28 29
29 // Collects unclean shutdown information and creates Crashpad minidumps. 30 // Collects unclean shutdown information and creates Crashpad minidumps.
30 // TODO(manzagop): throttling, graceful handling of accumulating data. 31 // TODO(manzagop): throttling, graceful handling of accumulating data.
31 // TODO(manzagop): UMA metrics and some error logging. 32 // TODO(manzagop): UMA metrics and some error logging.
32 class PostmortemReportCollector { 33 class PostmortemReportCollector {
33 public: 34 public:
34 // DO NOT CHANGE VALUES. This is logged persistently in a histogram. 35 // DO NOT CHANGE VALUES. This is logged persistently in a histogram.
35 enum CollectionStatus { 36 enum CollectionStatus {
36 NONE = 0, 37 NONE = 0,
37 SUCCESS = 1, // Successfully registered a report with Crashpad. 38 SUCCESS = 1, // Successfully registered a report with Crashpad.
38 ANALYZER_CREATION_FAILED = 2, 39 ANALYZER_CREATION_FAILED = 2,
39 DEBUG_FILE_NO_DATA = 3, 40 DEBUG_FILE_NO_DATA = 3,
40 PREPARE_NEW_CRASH_REPORT_FAILED = 4, 41 PREPARE_NEW_CRASH_REPORT_FAILED = 4,
41 WRITE_TO_MINIDUMP_FAILED = 5, 42 WRITE_TO_MINIDUMP_FAILED = 5,
42 DEBUG_FILE_DELETION_FAILED = 6, 43 DEBUG_FILE_DELETION_FAILED = 6,
43 FINISHED_WRITING_CRASH_REPORT_FAILED = 7, 44 FINISHED_WRITING_CRASH_REPORT_FAILED = 7,
44 COLLECTION_STATUS_MAX = 8 45 COLLECTION_STATUS_MAX = 8
45 }; 46 };
46 47
47 PostmortemReportCollector(const std::string& product_name, 48 PostmortemReportCollector(const std::string& product_name,
48 const std::string& version_number, 49 const std::string& version_number,
49 const std::string& channel_name); 50 const std::string& channel_name,
50 virtual ~PostmortemReportCollector() = default; 51 SystemSessionAnalyzer* analyzer);
52 virtual ~PostmortemReportCollector();
51 53
52 // Collects postmortem stability reports from files found in |debug_info_dir|, 54 // Collects postmortem stability reports from files found in |debug_info_dir|,
53 // relying on |debug_file_pattern| and |excluded_debug_files|. Reports are 55 // relying on |debug_file_pattern| and |excluded_debug_files|. Reports are
54 // then wrapped in Crashpad reports, manufactured via |report_database|. 56 // then wrapped in Crashpad reports, manufactured via |report_database|.
55 // Returns the number crash reports successfully registered with the reporter. 57 // Returns the number crash reports successfully registered with the reporter.
56 // TODO(manzagop): consider mechanisms for partial collection if this is to be 58 // TODO(manzagop): consider mechanisms for partial collection if this is to be
57 // used on a critical path. 59 // used on a critical path.
58 int CollectAndSubmitForUpload( 60 int CollectAndSubmitForUpload(
59 const base::FilePath& debug_info_dir, 61 const base::FilePath& debug_info_dir,
60 const base::FilePath::StringType& debug_file_pattern, 62 const base::FilePath::StringType& debug_file_pattern,
(...skipping 16 matching lines...) Expand all
77 LogCollection); 79 LogCollection);
78 FRIEND_TEST_ALL_PREFIXES( 80 FRIEND_TEST_ALL_PREFIXES(
79 PostmortemReportCollectorCollectionFromGlobalTrackerTest, 81 PostmortemReportCollectorCollectionFromGlobalTrackerTest,
80 GlobalUserDataCollection); 82 GlobalUserDataCollection);
81 FRIEND_TEST_ALL_PREFIXES( 83 FRIEND_TEST_ALL_PREFIXES(
82 PostmortemReportCollectorCollectionFromGlobalTrackerTest, 84 PostmortemReportCollectorCollectionFromGlobalTrackerTest,
83 FieldTrialCollection); 85 FieldTrialCollection);
84 FRIEND_TEST_ALL_PREFIXES( 86 FRIEND_TEST_ALL_PREFIXES(
85 PostmortemReportCollectorCollectionFromGlobalTrackerTest, 87 PostmortemReportCollectorCollectionFromGlobalTrackerTest,
86 ModuleCollection); 88 ModuleCollection);
89 FRIEND_TEST_ALL_PREFIXES(
90 PostmortemReportCollectorCollectionFromGlobalTrackerTest,
91 SystemStateTest);
87 92
88 // Virtual for unittesting. 93 // Virtual for unittesting.
89 virtual std::vector<base::FilePath> GetDebugStateFilePaths( 94 virtual std::vector<base::FilePath> GetDebugStateFilePaths(
90 const base::FilePath& debug_info_dir, 95 const base::FilePath& debug_info_dir,
91 const base::FilePath::StringType& debug_file_pattern, 96 const base::FilePath::StringType& debug_file_pattern,
92 const std::set<base::FilePath>& excluded_debug_files); 97 const std::set<base::FilePath>& excluded_debug_files);
93 98
94 CollectionStatus CollectAndSubmit( 99 CollectionStatus CollectAndSubmit(
95 const crashpad::UUID& client_id, 100 const crashpad::UUID& client_id,
96 const base::FilePath& file, 101 const base::FilePath& file,
97 crashpad::CrashReportDatabase* report_database); 102 crashpad::CrashReportDatabase* report_database);
98 103
99 // Virtual for unittesting. 104 // Virtual for unittesting.
100 // TODO(manzagop): move this for reuse in live scenario. 105 // TODO(manzagop): move this for reuse in live scenario.
101 virtual CollectionStatus Collect(const base::FilePath& debug_state_file, 106 virtual CollectionStatus Collect(const base::FilePath& debug_state_file,
Sigurður Ásgeirsson 2017/03/02 21:52:58 Nit: It would help the poor reader if there were a
manzagop (departed) 2017/03/06 15:37:40 If you're ok with it, let's leave that for https:/
102 std::unique_ptr<StabilityReport>* report); 107 std::unique_ptr<StabilityReport>* report);
108 void SetReporterDetails(StabilityReport* report) const;
109 void DetermineSystemState(StabilityReport* report) const;
103 void CollectThread( 110 void CollectThread(
104 const base::debug::ThreadActivityAnalyzer::Snapshot& snapshot, 111 const base::debug::ThreadActivityAnalyzer::Snapshot& snapshot,
105 ThreadState* thread_state); 112 ThreadState* thread_state);
106 113
107 virtual bool WriteReportToMinidump(StabilityReport* report, 114 virtual bool WriteReportToMinidump(StabilityReport* report,
108 const crashpad::UUID& client_id, 115 const crashpad::UUID& client_id,
109 const crashpad::UUID& report_id, 116 const crashpad::UUID& report_id,
110 base::PlatformFile minidump_file); 117 base::PlatformFile minidump_file);
111 118
112 std::string product_name_; 119 std::string product_name_;
113 std::string version_number_; 120 std::string version_number_;
114 std::string channel_name_; 121 std::string channel_name_;
115 122
123 SystemSessionAnalyzer* system_session_analyzer_; // Not owned.
124
116 DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector); 125 DISALLOW_COPY_AND_ASSIGN(PostmortemReportCollector);
117 }; 126 };
118 127
119 } // namespace browser_watcher 128 } // namespace browser_watcher
120 129
121 #endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_ 130 #endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_REPORT_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698