| OLD | NEW |
| 1 // Copyright (c) 2011 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 #include "chrome/browser/diagnostics/diagnostics_model.h" | 5 #include "chrome/browser/diagnostics/diagnostics_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // 1- Inserting the appropiate tests into |tests_| | 28 // 1- Inserting the appropiate tests into |tests_| |
| 29 // 2- Overriding RunTest() to wrap it with the appropiate fatal exception | 29 // 2- Overriding RunTest() to wrap it with the appropiate fatal exception |
| 30 // handler for the OS. | 30 // handler for the OS. |
| 31 // This class owns the all the tests and will only delete them upon | 31 // This class owns the all the tests and will only delete them upon |
| 32 // destruction. | 32 // destruction. |
| 33 class DiagnosticsModelImpl : public DiagnosticsModel { | 33 class DiagnosticsModelImpl : public DiagnosticsModel { |
| 34 public: | 34 public: |
| 35 DiagnosticsModelImpl() : tests_run_(0) { | 35 DiagnosticsModelImpl() : tests_run_(0) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 ~DiagnosticsModelImpl() { | 38 virtual ~DiagnosticsModelImpl() { |
| 39 STLDeleteElements(&tests_); | 39 STLDeleteElements(&tests_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual int GetTestRunCount() { | 42 virtual int GetTestRunCount() OVERRIDE { |
| 43 return tests_run_; | 43 return tests_run_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual int GetTestAvailableCount() { | 46 virtual int GetTestAvailableCount() OVERRIDE { |
| 47 return tests_.size(); | 47 return tests_.size(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void RunAll(DiagnosticsModel::Observer* observer) { | 50 virtual void RunAll(DiagnosticsModel::Observer* observer) OVERRIDE { |
| 51 size_t test_count = tests_.size(); | 51 size_t test_count = tests_.size(); |
| 52 for (size_t ix = 0; ix != test_count; ++ix) { | 52 for (size_t ix = 0; ix != test_count; ++ix) { |
| 53 bool do_next = RunTest(tests_[ix], observer, ix); | 53 bool do_next = RunTest(tests_[ix], observer, ix); |
| 54 ++tests_run_; | 54 ++tests_run_; |
| 55 if (!do_next) | 55 if (!do_next) |
| 56 break; | 56 break; |
| 57 } | 57 } |
| 58 observer->OnDoneAll(this); | 58 observer->OnDoneAll(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual TestInfo& GetTest(size_t id) { | 61 virtual TestInfo& GetTest(size_t id) OVERRIDE { |
| 62 return *tests_[id]; | 62 return *tests_[id]; |
| 63 } | 63 } |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 // Run a particular test. Return false if no other tests should be run. | 66 // Run a particular test. Return false if no other tests should be run. |
| 67 virtual bool RunTest(DiagnosticTest* test, Observer* observer, size_t index) { | 67 virtual bool RunTest(DiagnosticTest* test, Observer* observer, size_t index) { |
| 68 return test->Execute(observer, this, index); | 68 return test->Execute(observer, this, index); |
| 69 } | 69 } |
| 70 | 70 |
| 71 typedef std::vector<DiagnosticTest*> TestArray; | 71 typedef std::vector<DiagnosticTest*> TestArray; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (!user_data_dir.empty()) | 169 if (!user_data_dir.empty()) |
| 170 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); | 170 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); |
| 171 #if defined(OS_WIN) | 171 #if defined(OS_WIN) |
| 172 return new DiagnosticsModelWin(); | 172 return new DiagnosticsModelWin(); |
| 173 #elif defined(OS_MACOSX) | 173 #elif defined(OS_MACOSX) |
| 174 return new DiagnosticsModelMac(); | 174 return new DiagnosticsModelMac(); |
| 175 #elif defined(OS_POSIX) | 175 #elif defined(OS_POSIX) |
| 176 return new DiagnosticsModelPosix(); | 176 return new DiagnosticsModelPosix(); |
| 177 #endif | 177 #endif |
| 178 } | 178 } |
| OLD | NEW |