blob: 7e7ee17b4d5c35f46c84b316ff9ee5609f53721d [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
8#include "base/memory/scoped_ptr.h"
9#include "base/memory/singleton.h"
10
[email protected]2f3b1cc2014-03-17 23:07:1511namespace base {
[email protected]f22fae42013-07-09 21:11:1112class CommandLine;
[email protected]2f3b1cc2014-03-17 23:07:1513}
[email protected]f22fae42013-07-09 21:11:1114
15namespace diagnostics {
16
17class DiagnosticsWriter;
18class DiagnosticsModel;
19
20class DiagnosticsController {
21 public:
22 static DiagnosticsController* GetInstance();
23
24 // Entry point for the diagnostics mode. Returns zero if able to run
25 // diagnostics successfully, regardless of the results of the diagnostics.
[email protected]2f3b1cc2014-03-17 23:07:1526 int Run(const base::CommandLine& command_line, DiagnosticsWriter* writer);
[email protected]f22fae42013-07-09 21:11:1127
[email protected]60756be2013-08-07 05:20:2628 // Entry point for running recovery based on diagnostics that have already
29 // been run. In order for this to do anything, Run() must be executed first.
[email protected]2f3b1cc2014-03-17 23:07:1530 int RunRecovery(const base::CommandLine& command_line,
31 DiagnosticsWriter* writer);
[email protected]60756be2013-08-07 05:20:2632
33 // Returns a model with the results that have accumulated. They can then be
[email protected]f22fae42013-07-09 21:11:1134 // queried for their attributes for human consumption later.
35 const DiagnosticsModel& GetResults() const;
36
37 // Returns true if there are any results available.
38 bool HasResults();
39
40 // Clears any results that have accumulated. After calling this, do not call
41 // GetResults until after Run is called again.
42 void ClearResults();
43
[email protected]0c38b262013-08-23 23:34:2444 // Records UMA statistics indicating that a regular Chrome startup happened,
45 // with no diagnostics or recovery being run. This is necessary to provide a
46 // denominator for the diagnostics metrics.
47 void RecordRegularStartup();
48
[email protected]f22fae42013-07-09 21:11:1149 private:
50 friend struct DefaultSingletonTraits<DiagnosticsController>;
51
52 DiagnosticsController();
53 ~DiagnosticsController();
54
55 scoped_ptr<DiagnosticsModel> model_;
56 DiagnosticsWriter* writer_;
57
58 DISALLOW_COPY_AND_ASSIGN(DiagnosticsController);
59};
60
61} // namespace diagnostics
62
63#endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_CONTROLLER_H_