diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 04:50:58 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 04:50:58 +0000 |
commit | aedc9960f80930f1c5ed1059660f822533792bb9 (patch) | |
tree | aeff6028eefc73c5c88dd02a73f6ce821197ba66 /chrome/browser/diagnostics/diagnostics_model.h | |
parent | 74cda952e5725e71f2294d741ecde4424e760f48 (diff) | |
download | chromium_src-aedc9960f80930f1c5ed1059660f822533792bb9.zip chromium_src-aedc9960f80930f1c5ed1059660f822533792bb9.tar.gz chromium_src-aedc9960f80930f1c5ed1059660f822533792bb9.tar.bz2 |
Introducing the diagnostic model classes
Chrome diagnostics wants to be a MVC, this is the classes that compose the model part.
BUG=27885
TEST=included unit tests
Review URL: http://codereview.chromium.org/385144
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/diagnostics/diagnostics_model.h')
-rw-r--r-- | chrome/browser/diagnostics/diagnostics_model.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/chrome/browser/diagnostics/diagnostics_model.h b/chrome/browser/diagnostics/diagnostics_model.h new file mode 100644 index 0000000..bb977ef --- /dev/null +++ b/chrome/browser/diagnostics/diagnostics_model.h @@ -0,0 +1,75 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ +#define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ + +#include "base/string16.h" + +// The chrome diagnostics system is a model-view-controller system. The Model +// responsible for holding and running the individual tests and providing a +// uniform interface for quering the outcome. +// TODO (CPU): The view and the controller are not yet built. +class DiagnosticsModel { + public: + // A particular test can be in one of the following states. + enum TestResult { + TEST_NOT_RUN, + TEST_RUNNING, + TEST_OK, + TEST_FAIL_CONTINUE, + TEST_FAIL_STOP, + }; + + // Observer derived form this class which provides a way to be notified of + // changes to the model as the tests are run. For all the callbacks |id| + // is the index of the test in question and information can be obtained by + // calling model->GetTest(id). + class Observer { + public: + virtual ~Observer() {} + // Called once upon test start with |percent| = 0 and periodically as the + // test progresses. There is no cancelation method. + virtual void OnProgress(int id, int percent, DiagnosticsModel* model) = 0; + // Called if the test in question cannot be run. + virtual void OnSkipped(int id, DiagnosticsModel* model) = 0; + // Called when the test has finished regardless of outcome. + virtual void OnFinished(int id, DiagnosticsModel* model) = 0; + // Called once all the test are run. + virtual void OnDoneAll(DiagnosticsModel* model) = 0; + }; + + // Encapsulates what you can know about a given test. + class TestInfo { + public: + virtual ~TestInfo() {} + // A human readable, localized string that tells you what is being tested. + virtual string16 GetTitle() = 0; + // The result of running the test. If called before the test is ran the + // answer is TEST_NOT_RUN. + virtual TestResult GetResult() = 0; + // A human readable, localized string that tells you what happened. If + // called before the test is run it returns the empty string. + virtual string16 GetAdditionalInfo() = 0; + }; + + virtual ~DiagnosticsModel() {} + // Returns how many tests have been run. + virtual int GetTestRunCount() = 0; + // Returns how many tests are available. This value never changes. + virtual int GetTestAvailableCount() =0; + // Runs all the availabe tests, the |observer| callbacks will be called as + // the test progress and thus cannot be null. + virtual void RunAll(DiagnosticsModel::Observer* observer) = 0; + // Get the information for a particular test. Do not keep a pointer to the + // returned object. + virtual TestInfo& GetTest(size_t id) = 0; +}; + +// The factory for the model. The main purpose is to hide the creation of +// different models for different platforms. +DiagnosticsModel* MakeDiagnosticsModel(); + + +#endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_MODEL_H_ |