blob: a98608b3e5475d120fa126bc89cb41d37d0c4713 [file] [log] [blame]
[email protected]f22fae42013-07-09 21:11:111// 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
dcheng4af48582016-04-19 00:29:358#include <memory>
9
avie4d7b6f2015-12-26 00:59:1810#include "base/macros.h"
[email protected]f22fae42013-07-09 21:11:1111#include "base/memory/singleton.h"
12
[email protected]2f3b1cc2014-03-17 23:07:1513namespace base {
[email protected]f22fae42013-07-09 21:11:1114class CommandLine;
[email protected]2f3b1cc2014-03-17 23:07:1515}
[email protected]f22fae42013-07-09 21:11:1116
17namespace diagnostics {
18
19class DiagnosticsWriter;
20class DiagnosticsModel;
21
22class 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]2f3b1cc2014-03-17 23:07:1528 int Run(const base::CommandLine& command_line, DiagnosticsWriter* writer);
[email protected]f22fae42013-07-09 21:11:1129
[email protected]60756be2013-08-07 05:20:2630 // 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]2f3b1cc2014-03-17 23:07:1532 int RunRecovery(const base::CommandLine& command_line,
33 DiagnosticsWriter* writer);
[email protected]60756be2013-08-07 05:20:2634
35 // Returns a model with the results that have accumulated. They can then be
[email protected]f22fae42013-07-09 21:11:1136 // 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]0c38b262013-08-23 23:34:2446 // 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]f22fae42013-07-09 21:11:1151 private:
olli.raula36aa8be2015-09-10 11:14:2252 friend struct base::DefaultSingletonTraits<DiagnosticsController>;
[email protected]f22fae42013-07-09 21:11:1153
54 DiagnosticsController();
55 ~DiagnosticsController();
56
dcheng4af48582016-04-19 00:29:3557 std::unique_ptr<DiagnosticsModel> model_;
[email protected]f22fae42013-07-09 21:11:1158 DiagnosticsWriter* writer_;
59
60 DISALLOW_COPY_AND_ASSIGN(DiagnosticsController);
61};
62
63} // namespace diagnostics
64
65#endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_CONTROLLER_H_