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