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