This updates and cleans up the chrome diagnostics mode so that it includes some integrity checking for NSS databases on ChromeOS.
Added the concept of an "outcome code" that would allow individual tests to provide specific information about what the failure was.
Also, removed references to wstring, and generally made error messages more consistent in style.
Added two more modes (besides human-readable) for output of the results so that it could more easily be used for input to a program (--diagnostics-format=machine), and so that the output can be sent to the chrome log instead of creating/using a console at all (--diagnostics-format=log).
Rearranged the code so that diagnostics mode can be run in a mode that doesn't require internationalization code to be initialized (or indeed provide any output mode), so that it could be still be run early and let chrome continue running and deliver results to the user later when more UI layers are available.
Removed building of diagnostics code from the Android build.
These changes are in preparation for adding a "recovery" option to attempt to recover from profile corruption on ChromeOS when we detect that chrome has crashed and restarted.
[email protected]
BUG=chromium:236093
Review URL: https://chromiumcodereview.appspot.com/16905002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210617 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/diagnostics/diagnostics_test.cc b/chrome/browser/diagnostics/diagnostics_test.cc
index 64d4797c..fe08dd6 100644
--- a/chrome/browser/diagnostics/diagnostics_test.cc
+++ b/chrome/browser/diagnostics/diagnostics_test.cc
@@ -9,45 +9,61 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
-DiagnosticTest::DiagnosticTest(const string16& title)
- : title_(title), result_(DiagnosticsModel::TEST_NOT_RUN) {
-}
+namespace diagnostics {
-DiagnosticTest::~DiagnosticTest() {
-}
+DiagnosticsTest::DiagnosticsTest(const std::string& id,
+ const std::string& title)
+ : id_(id),
+ title_(title),
+ outcome_code_(-1),
+ result_(DiagnosticsModel::TEST_NOT_RUN) {}
-bool DiagnosticTest::Execute(DiagnosticsModel::Observer* observer,
- DiagnosticsModel* model,
- size_t index) {
+DiagnosticsTest::~DiagnosticsTest() {}
+
+bool DiagnosticsTest::Execute(DiagnosticsModel::Observer* observer,
+ DiagnosticsModel* model,
+ size_t index) {
+ start_time_ = base::Time::Now();
result_ = DiagnosticsModel::TEST_RUNNING;
- observer->OnProgress(index, 0, model);
bool keep_going = ExecuteImpl(observer);
- observer->OnFinished(index, model);
+ if (observer)
+ observer->OnFinished(index, model);
return keep_going;
}
-string16 DiagnosticTest::GetTitle() {
- return title_;
-}
-
-DiagnosticsModel::TestResult DiagnosticTest::GetResult() {
- return result_;
-}
-
-string16 DiagnosticTest::GetAdditionalInfo() {
- return additional_info_;
-}
-
-void DiagnosticTest::RecordOutcome(const string16& additional_info,
- DiagnosticsModel::TestResult result) {
+void DiagnosticsTest::RecordOutcome(int outcome_code,
+ const std::string& additional_info,
+ DiagnosticsModel::TestResult result) {
+ end_time_ = base::Time::Now();
+ outcome_code_ = outcome_code;
additional_info_ = additional_info;
result_ = result;
}
// static
-base::FilePath DiagnosticTest::GetUserDefaultProfileDir() {
+base::FilePath DiagnosticsTest::GetUserDefaultProfileDir() {
base::FilePath path;
if (!PathService::Get(chrome::DIR_USER_DATA, &path))
return base::FilePath();
return path.AppendASCII(chrome::kInitialProfile);
}
+
+std::string DiagnosticsTest::GetId() const { return id_; }
+
+std::string DiagnosticsTest::GetTitle() const { return title_; }
+
+DiagnosticsModel::TestResult DiagnosticsTest::GetResult() const {
+ return result_;
+}
+
+int DiagnosticsTest::GetOutcomeCode() const { return outcome_code_; }
+
+std::string DiagnosticsTest::GetAdditionalInfo() const {
+ return additional_info_;
+}
+
+base::Time DiagnosticsTest::GetStartTime() const { return start_time_; }
+
+base::Time DiagnosticsTest::GetEndTime() const { return end_time_; }
+
+} // namespace diagnostics