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

Side by Side Diff: chrome/browser/diagnostics/diagnostics_model.h

Issue 6098004: Integrate about:conflicts with --diagnostics... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ 5 #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_
6 #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ 6 #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 10
11 class CommandLine; 11 class CommandLine;
12 12
13 // The chrome diagnostics system is a model-view-controller system. The Model 13 // The chrome diagnostics system is a model-view-controller system. The Model
14 // responsible for holding and running the individual tests and providing a 14 // responsible for holding and running the individual tests and providing a
15 // uniform interface for quering the outcome. 15 // uniform interface for querying the outcome.
16 // TODO(cpu): The view and the controller are not yet built. 16 // TODO(cpu): The view and the controller are not yet built.
17 class DiagnosticsModel { 17 class DiagnosticsModel {
18 public: 18 public:
19 // A particular test can be in one of the following states. 19 // A particular test can be in one of the following states.
20 enum TestResult { 20 enum TestResult {
21 TEST_NOT_RUN, 21 TEST_NOT_RUN,
22 TEST_RUNNING, 22 TEST_RUNNING,
23 TEST_OK, 23 TEST_OK,
24 TEST_FAIL_CONTINUE, 24 TEST_FAIL_CONTINUE,
25 TEST_FAIL_STOP, 25 TEST_FAIL_STOP,
26 }; 26 };
27 27
28 // Observer derived form this class which provides a way to be notified of 28 // Observer derived form this class which provides a way to be notified of
29 // changes to the model as the tests are run. For all the callbacks |id| 29 // changes to the model as the tests are run. For all the callbacks |id|
30 // is the index of the test in question and information can be obtained by 30 // is the index of the test in question and information can be obtained by
31 // calling model->GetTest(id). 31 // calling model->GetTest(id).
32 class Observer { 32 class Observer {
33 public: 33 public:
34 virtual ~Observer() {} 34 virtual ~Observer() {}
35 // Called once upon test start with |percent| = 0 and periodically as the 35 // Called once upon test start with |percent| = 0 and periodically as the
36 // test progresses. There is no cancelation method. 36 // test progresses. There is no cancellation method.
37 virtual void OnProgress(int id, int percent, DiagnosticsModel* model) = 0; 37 virtual void OnProgress(int id, int percent, DiagnosticsModel* model) = 0;
38 // Called if the test in question cannot be run. 38 // Called if the test in question cannot be run.
39 virtual void OnSkipped(int id, DiagnosticsModel* model) = 0; 39 virtual void OnSkipped(int id, DiagnosticsModel* model) = 0;
40 // Called when the test has finished regardless of outcome. 40 // Called when the test has finished regardless of outcome.
41 virtual void OnFinished(int id, DiagnosticsModel* model) = 0; 41 virtual void OnFinished(int id, DiagnosticsModel* model) = 0;
42 // Called once all the test are run. 42 // Called once all the test are run.
43 virtual void OnDoneAll(DiagnosticsModel* model) = 0; 43 virtual void OnDoneAll(DiagnosticsModel* model) = 0;
44 }; 44 };
45 45
46 // Encapsulates what you can know about a given test. 46 // Encapsulates what you can know about a given test.
47 class TestInfo { 47 class TestInfo {
48 public: 48 public:
49 virtual ~TestInfo() {} 49 virtual ~TestInfo() {}
50 // A human readable, localized string that tells you what is being tested. 50 // A human readable, localized string that tells you what is being tested.
51 virtual string16 GetTitle() = 0; 51 virtual string16 GetTitle() = 0;
52 // The result of running the test. If called before the test is ran the 52 // The result of running the test. If called before the test is ran the
53 // answer is TEST_NOT_RUN. 53 // answer is TEST_NOT_RUN.
54 virtual TestResult GetResult() = 0; 54 virtual TestResult GetResult() = 0;
55 // A human readable, localized string that tells you what happened. If 55 // A human readable, localized string that tells you what happened. If
56 // called before the test is run it returns the empty string. 56 // called before the test is run it returns the empty string.
57 virtual string16 GetAdditionalInfo() = 0; 57 virtual string16 GetAdditionalInfo() = 0;
58 }; 58 };
59 59
60 virtual ~DiagnosticsModel() {} 60 virtual ~DiagnosticsModel() {}
61 // Returns how many tests have been run. 61 // Returns how many tests have been run.
62 virtual int GetTestRunCount() = 0; 62 virtual int GetTestRunCount() = 0;
63 // Returns how many tests are available. This value never changes. 63 // Returns how many tests are available. This value never changes.
64 virtual int GetTestAvailableCount() =0; 64 virtual int GetTestAvailableCount() =0;
65 // Runs all the availabe tests, the |observer| callbacks will be called as 65 // Runs all the available tests, the |observer| callbacks will be called as
66 // the test progress and thus cannot be null. 66 // the test progress and thus cannot be null.
67 virtual void RunAll(DiagnosticsModel::Observer* observer) = 0; 67 virtual void RunAll(DiagnosticsModel::Observer* observer) = 0;
68 // Get the information for a particular test. Do not keep a pointer to the 68 // Get the information for a particular test. Do not keep a pointer to the
69 // returned object. 69 // returned object.
70 virtual TestInfo& GetTest(size_t id) = 0; 70 virtual TestInfo& GetTest(size_t id) = 0;
71 }; 71 };
72 72
73 // The factory for the model. The main purpose is to hide the creation of 73 // The factory for the model. The main purpose is to hide the creation of
74 // different models for different platforms. 74 // different models for different platforms.
75 DiagnosticsModel* MakeDiagnosticsModel(const CommandLine& cmdline); 75 DiagnosticsModel* MakeDiagnosticsModel(const CommandLine& cmdline);
76 76
77 77
78 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ 78 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/diagnostics/diagnostics_main.cc ('k') | chrome/browser/diagnostics/diagnostics_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698