diff options
Diffstat (limited to 'chrome/browser/diagnostics/diagnostics_model.cc')
| -rw-r--r-- | chrome/browser/diagnostics/diagnostics_model.cc | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/chrome/browser/diagnostics/diagnostics_model.cc b/chrome/browser/diagnostics/diagnostics_model.cc index dc6b35a..54da906 100644 --- a/chrome/browser/diagnostics/diagnostics_model.cc +++ b/chrome/browser/diagnostics/diagnostics_model.cc @@ -13,6 +13,7 @@ #include "base/string_util.h" #include "base/path_service.h" #include "chrome/browser/diagnostics/diagnostics_test.h" +#include "chrome/browser/diagnostics/recon_diagnostics.h" #include "chrome/common/chrome_paths.h" namespace { @@ -45,7 +46,7 @@ class DiagnosticsModelImpl : public DiagnosticsModel { virtual void RunAll(DiagnosticsModel::Observer* observer) { size_t test_count = tests_.size(); for (size_t ix = 0; ix != test_count; ++ix) { - bool do_next = RunTest(tests_[ix], observer); + bool do_next = RunTest(tests_[ix], observer, ix); ++tests_run_; if (!do_next) break; @@ -59,8 +60,8 @@ class DiagnosticsModelImpl : public DiagnosticsModel { protected: // Run a particular test. Return false if no other tests should be run. - virtual bool RunTest(DiagnosticTest* test, Observer* observer) { - return test->Execute(observer, this); + virtual bool RunTest(DiagnosticTest* test, Observer* observer, size_t index) { + return test->Execute(observer, this, index); } typedef std::vector<DiagnosticTest*> TestArray; @@ -71,47 +72,19 @@ class DiagnosticsModelImpl : public DiagnosticsModel { DISALLOW_COPY_AND_ASSIGN(DiagnosticsModelImpl); }; -// Simple basic diagnostic test. Check that the user's data directory -// exists. This test works for all platforms. -// TODO(cpu): Move to its final place. -// TODO(cpu): Localize strings. -class UserPathsTest : public DiagnosticTest { - public: - UserPathsTest() : DiagnosticTest(ASCIIToUTF16("User data Directory")) {} - - // Not used at the moment but it allows one test to query the status - // of another test so we can build test dependencies. - virtual int GetId() { return 0; } - - virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { - FilePath dir; - if (!PathService::Get(chrome::DIR_USER_DATA, &dir)) { - RecordStopFailure(ASCIIToUTF16("Path provider failure")); - return false; - } - if (!file_util::PathExists(dir)) { - RecordFailure(ASCIIToUTF16("No user data dir found")); - return true; - } - if (!file_util::PathIsWritable(dir)) { - RecordFailure(ASCIIToUTF16("User data dir is not writable")); - return true; - } - RecordSuccess(ASCIIToUTF16("Directory exists and is writable")); - return true; - } - - private: - DISALLOW_COPY_AND_ASSIGN(UserPathsTest); -}; - // Each platform can have their own tests. For the time being there is only // one test that works on all platforms. #if defined(OS_WIN) class DiagnosticsModelWin : public DiagnosticsModelImpl { public: DiagnosticsModelWin() { - tests_.push_back(new UserPathsTest()); + tests_.push_back(MakeWinOsIdTest()); + tests_.push_back(MakeInstallTypeTest()); + tests_.push_back(MakeUserDirTest()); + tests_.push_back(MakeResourceFileTest()); + tests_.push_back(MakeLocalStateFileTest()); + tests_.push_back(MakeDictonaryDirTest()); + tests_.push_back(MakeInspectorDirTest()); } private: @@ -122,7 +95,12 @@ class DiagnosticsModelWin : public DiagnosticsModelImpl { class DiagnosticsModelMac : public DiagnosticsModelImpl { public: DiagnosticsModelMac() { - tests_.push_back(new UserPathsTest()); + tests_.push_back(MakeInstallTypeTest()); + tests_.push_back(MakeUserDirTest()); + tests_.push_back(MakeResourceFileTest()); + tests_.push_back(MakeLocalStateFileTest()); + tests_.push_back(MakeDictonaryDirTest()); + tests_.push_back(MakeInspectorDirTest()); } private: DISALLOW_COPY_AND_ASSIGN(DiagnosticsModelMac); @@ -132,7 +110,12 @@ class DiagnosticsModelMac : public DiagnosticsModelImpl { class DiagnosticsModelLinux : public DiagnosticsModelImpl { public: DiagnosticsModelLinux() { - tests_.push_back(new UserPathsTest()); + tests_.push_back(MakeInstallTypeTest()); + tests_.push_back(MakeUserDirTest()); + tests_.push_back(MakeResourceFileTest()); + tests_.push_back(MakeLocalStateFileTest()); + tests_.push_back(MakeDictonaryDirTest()); + tests_.push_back(MakeInspectorDirTest()); } private: DISALLOW_COPY_AND_ASSIGN(DiagnosticsModelLinux); |
