[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 1 | // Copyright 2013 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 | #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_CONTROLLER_H_ | ||||
6 | #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_CONTROLLER_H_ | ||||
7 | |||||
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 10 | #include "base/macros.h" |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 11 | #include "base/memory/singleton.h" |
12 | |||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 13 | namespace base { |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 14 | class CommandLine; |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 15 | } |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 16 | |
17 | namespace diagnostics { | ||||
18 | |||||
19 | class DiagnosticsWriter; | ||||
20 | class DiagnosticsModel; | ||||
21 | |||||
22 | class DiagnosticsController { | ||||
23 | public: | ||||
24 | static DiagnosticsController* GetInstance(); | ||||
25 | |||||
26 | // Entry point for the diagnostics mode. Returns zero if able to run | ||||
27 | // diagnostics successfully, regardless of the results of the diagnostics. | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 28 | int Run(const base::CommandLine& command_line, DiagnosticsWriter* writer); |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 29 | |
[email protected] | 60756be | 2013-08-07 05:20:26 | [diff] [blame] | 30 | // Entry point for running recovery based on diagnostics that have already |
31 | // been run. In order for this to do anything, Run() must be executed first. | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 32 | int RunRecovery(const base::CommandLine& command_line, |
33 | DiagnosticsWriter* writer); | ||||
[email protected] | 60756be | 2013-08-07 05:20:26 | [diff] [blame] | 34 | |
35 | // Returns a model with the results that have accumulated. They can then be | ||||
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 36 | // queried for their attributes for human consumption later. |
37 | const DiagnosticsModel& GetResults() const; | ||||
38 | |||||
39 | // Returns true if there are any results available. | ||||
40 | bool HasResults(); | ||||
41 | |||||
42 | // Clears any results that have accumulated. After calling this, do not call | ||||
43 | // GetResults until after Run is called again. | ||||
44 | void ClearResults(); | ||||
45 | |||||
[email protected] | 0c38b26 | 2013-08-23 23:34:24 | [diff] [blame] | 46 | // Records UMA statistics indicating that a regular Chrome startup happened, |
47 | // with no diagnostics or recovery being run. This is necessary to provide a | ||||
48 | // denominator for the diagnostics metrics. | ||||
49 | void RecordRegularStartup(); | ||||
50 | |||||
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 51 | private: |
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 52 | friend struct base::DefaultSingletonTraits<DiagnosticsController>; |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 53 | |
54 | DiagnosticsController(); | ||||
55 | ~DiagnosticsController(); | ||||
56 | |||||
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 57 | std::unique_ptr<DiagnosticsModel> model_; |
[email protected] | f22fae4 | 2013-07-09 21:11:11 | [diff] [blame] | 58 | DiagnosticsWriter* writer_; |
59 | |||||
60 | DISALLOW_COPY_AND_ASSIGN(DiagnosticsController); | ||||
61 | }; | ||||
62 | |||||
63 | } // namespace diagnostics | ||||
64 | |||||
65 | #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_CONTROLLER_H_ |