diff options
| author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 00:11:41 +0000 |
|---|---|---|
| committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 00:11:41 +0000 |
| commit | 2cfcf5c0ef8dad0a87985e21a22d6eff8cc0b37a (patch) | |
| tree | cf7f8debf92584ba058bee21f914a3db9bc36b55 /chrome/browser/diagnostics/sqlite_diagnostics.cc | |
| parent | 85ff70b6c85d318bb2326ef317237542a709436f (diff) | |
| download | chromium_src-2cfcf5c0ef8dad0a87985e21a22d6eff8cc0b37a.zip chromium_src-2cfcf5c0ef8dad0a87985e21a22d6eff8cc0b37a.tar.gz chromium_src-2cfcf5c0ef8dad0a87985e21a22d6eff8cc0b37a.tar.bz2 | |
Revert 43143 - Implement db corruption tests for diagnostic mode
Uses sqlite's pragma integrity_check
Tests the 5 main databases
BUG=27885
TEST=none
Review URL: http://codereview.chromium.org/1548005
TBR=cpu@chromium.org
Review URL: http://codereview.chromium.org/1539006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/diagnostics/sqlite_diagnostics.cc')
| -rw-r--r-- | chrome/browser/diagnostics/sqlite_diagnostics.cc | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.cc b/chrome/browser/diagnostics/sqlite_diagnostics.cc index e0eeab3..fbefc33 100644 --- a/chrome/browser/diagnostics/sqlite_diagnostics.cc +++ b/chrome/browser/diagnostics/sqlite_diagnostics.cc @@ -5,16 +5,9 @@ #include "chrome/browser/diagnostics/sqlite_diagnostics.h" #include "app/sql/connection.h" -#include "app/sql/init_status.h" -#include "app/sql/statement.h" -#include "base/file_util.h" #include "base/histogram.h" #include "base/logging.h" -#include "base/path_service.h" #include "base/singleton.h" -#include "base/string_util.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_paths.h" namespace { @@ -54,74 +47,6 @@ class BasicSqliteErrrorHandler : public sql::ErrorDelegate { } }; -struct DbTestInfo { - const char* test_name; - const FilePath::CharType* db_name; -}; - -static const DbTestInfo kTestInfo[] = { - {"Web Database", chrome::kWebDataFilename}, - {"Cookies Database", chrome::kCookieFilename}, - {"History Database", chrome::kHistoryFilename}, - {"Archived history Database", chrome::kArchivedHistoryFilename}, - {"Thumbnails Database", chrome::kThumbnailsFilename} -}; - -// Generic diagnostic test class for checking sqlite db integrity. -class SqliteIntegrityTest : public DiagnosticTest { - public: - explicit SqliteIntegrityTest(int index) - : DiagnosticTest(ASCIIToUTF16(kTestInfo[index].test_name)), - index_(index) { - } - - virtual int GetId() { return 0; } - - virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { - FilePath path; - PathService::Get(chrome::DIR_USER_DATA, &path); - path = path.Append(FilePath::FromWStringHack(chrome::kNotSignedInProfile)); - path = path.Append(kTestInfo[index_].db_name); - if (!file_util::PathExists(path)) { - RecordFailure(ASCIIToUTF16("File not found")); - return true; - } - - int errors = 0; - { // This block scopes the lifetime of the db objects. - sql::Connection db; - db.set_exclusive_locking(); - if (!db.Open(path)) { - RecordFailure(ASCIIToUTF16("Cannot open db. Possibly corrupted")); - return true; - } - sql::Statement s(db.GetUniqueStatement("PRAGMA integrity_check;")); - if (!s) { - RecordFailure(ASCIIToUTF16("Statement failed")); - return false; - } - while (s.Step()) { - std::string result(s.ColumnString(0)); - if ("ok" != result) - ++errors; - } - } - // All done. Report to the user. - if (errors != 0) { - string16 str(ASCIIToUTF16("Database corruption detected :")); - str += IntToString16(errors) + ASCIIToUTF16(" errors"); - RecordFailure(str); - return true; - } - RecordSuccess(ASCIIToUTF16("no corruption detected")); - return true; - } - - private: - int index_; - DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest); -}; - } // namespace sql::ErrorDelegate* GetErrorHandlerForCookieDb() { @@ -143,24 +68,3 @@ sql::ErrorDelegate* GetErrorHandlerForTextDb() { sql::ErrorDelegate* GetErrorHandlerForWebDb() { return new BasicSqliteErrrorHandler<4>(); } - -DiagnosticTest* MakeSqliteWebDbTest() { - return new SqliteIntegrityTest(0); -} - -DiagnosticTest* MakeSqliteCookiesDbTest() { - return new SqliteIntegrityTest(1); -} - -DiagnosticTest* MakeSqliteHistoryDbTest() { - return new SqliteIntegrityTest(2); -} - -DiagnosticTest* MakeSqliteArchivedHistoryDbTest() { - return new SqliteIntegrityTest(3); -} - -DiagnosticTest* MakeSqliteThumbnailsDbTest() { - return new SqliteIntegrityTest(4); -} - |
