summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 22:12:56 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 22:12:56 +0000
commit4cccc224e222ceeb765ce93d5bb40223b210c472 (patch)
tree34c0d1c03d688288801e372282e560631148a692 /chrome
parentc692dd33c9a2686d7121045de78e7a0bdfabfe86 (diff)
downloadchromium_src-4cccc224e222ceeb765ce93d5bb40223b210c472.zip
chromium_src-4cccc224e222ceeb765ce93d5bb40223b210c472.tar.gz
chromium_src-4cccc224e222ceeb765ce93d5bb40223b210c472.tar.bz2
Include the appcache and database tracker databases into the sql diagnostics fold.
TEST=manual BUG=none Review URL: http://codereview.chromium.org/1508016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43534 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/diagnostics/diagnostics_model.cc8
-rw-r--r--chrome/browser/diagnostics/diagnostics_model_unittest.cc6
-rw-r--r--chrome/browser/diagnostics/sqlite_diagnostics.cc122
-rw-r--r--chrome/browser/diagnostics/sqlite_diagnostics.h4
4 files changed, 69 insertions, 71 deletions
diff --git a/chrome/browser/diagnostics/diagnostics_model.cc b/chrome/browser/diagnostics/diagnostics_model.cc
index b7a1bc3..cf27ab7 100644
--- a/chrome/browser/diagnostics/diagnostics_model.cc
+++ b/chrome/browser/diagnostics/diagnostics_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -92,6 +92,8 @@ class DiagnosticsModelWin : public DiagnosticsModelImpl {
tests_.push_back(MakeSqliteHistoryDbTest());
tests_.push_back(MakeSqliteArchivedHistoryDbTest());
tests_.push_back(MakeSqliteThumbnailsDbTest());
+ tests_.push_back(MakeSqliteAppCacheDbTest());
+ tests_.push_back(MakeSqliteWebDatabaseTrackerDbTest());
}
private:
@@ -113,6 +115,8 @@ class DiagnosticsModelMac : public DiagnosticsModelImpl {
tests_.push_back(MakeSqliteHistoryDbTest());
tests_.push_back(MakeSqliteArchivedHistoryDbTest());
tests_.push_back(MakeSqliteThumbnailsDbTest());
+ tests_.push_back(MakeSqliteAppCacheDbTest());
+ tests_.push_back(MakeSqliteWebDatabaseTrackerDbTest());
}
private:
@@ -134,6 +138,8 @@ class DiagnosticsModelPosix : public DiagnosticsModelImpl {
tests_.push_back(MakeSqliteHistoryDbTest());
tests_.push_back(MakeSqliteArchivedHistoryDbTest());
tests_.push_back(MakeSqliteThumbnailsDbTest());
+ tests_.push_back(MakeSqliteAppCacheDbTest());
+ tests_.push_back(MakeSqliteWebDatabaseTrackerDbTest());
}
private:
diff --git a/chrome/browser/diagnostics/diagnostics_model_unittest.cc b/chrome/browser/diagnostics/diagnostics_model_unittest.cc
index 3db4912..c6e3aaf 100644
--- a/chrome/browser/diagnostics/diagnostics_model_unittest.cc
+++ b/chrome/browser/diagnostics/diagnostics_model_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -72,9 +72,9 @@ class UTObserver: public DiagnosticsModel::Observer {
// We currently have more tests operational on windows.
#if defined(OS_WIN)
-const int kDiagnosticsTestCount = 13;
+const int kDiagnosticsTestCount = 15;
#else
-const int kDiagnosticsTestCount = 11;
+const int kDiagnosticsTestCount = 13;
#endif
// Test that the initial state is correct.
diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.cc b/chrome/browser/diagnostics/sqlite_diagnostics.cc
index e0eeab3..0cdc34c 100644
--- a/chrome/browser/diagnostics/sqlite_diagnostics.cc
+++ b/chrome/browser/diagnostics/sqlite_diagnostics.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
#include "chrome/browser/diagnostics/sqlite_diagnostics.h"
#include "app/sql/connection.h"
+#include "app/sql/diagnostic_error_delegate.h"
#include "app/sql/init_status.h"
#include "app/sql/statement.h"
#include "base/file_util.h"
@@ -15,64 +16,17 @@
#include "base/string_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
+#include "webkit/appcache/appcache_interfaces.h"
+#include "webkit/database/database_tracker.h"
namespace {
-const char* kHistogramNames[] = {
- "Sqlite.Cookie.Error",
- "Sqlite.History.Error",
- "Sqlite.Thumbnail.Error",
- "Sqlite.Text.Error",
- "Sqlite.Web.Error"
-};
-
-// This class handles the exceptional sqlite errors that we might encounter
-// if for example the db is corrupted. Right now we just generate a UMA
-// histogram for release and an assert for debug builds.
-//
-// Why is it a template you ask? well, that is a funny story. The histograms
-// need to be singletons that is why they are always static at the function
-// scope, but we cannot use the Singleton class because they are not default
-// constructible. The template parameter makes the compiler to create unique
-// classes that don't share the same static variable.
-template <size_t unique>
-class BasicSqliteErrrorHandler : public sql::ErrorDelegate {
- public:
-
- virtual int OnError(int error, sql::Connection* connection,
- sql::Statement* stmt) {
- NOTREACHED() << "sqlite error " << error;
- RecordErrorInHistogram(error);
- return error;
- }
-
- private:
- static void RecordErrorInHistogram(int error) {
- // The histogram values from sqlite result codes go currently from 1 to
- // 26 currently but 50 gives them room to grow.
- UMA_HISTOGRAM_ENUMERATION(kHistogramNames[unique], error, 50);
- }
-};
-
-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) {
+ SqliteIntegrityTest(
+ const string16& title, const FilePath& profile_relative_db_path)
+ : DiagnosticTest(title), db_path_(profile_relative_db_path) {
}
virtual int GetId() { return 0; }
@@ -81,9 +35,9 @@ class SqliteIntegrityTest : public DiagnosticTest {
FilePath path;
PathService::Get(chrome::DIR_USER_DATA, &path);
path = path.Append(FilePath::FromWStringHack(chrome::kNotSignedInProfile));
- path = path.Append(kTestInfo[index_].db_name);
+ path = path.Append(db_path_);
if (!file_util::PathExists(path)) {
- RecordFailure(ASCIIToUTF16("File not found"));
+ RecordSuccess(ASCIIToUTF16("File not found"));
return true;
}
@@ -118,49 +72,85 @@ class SqliteIntegrityTest : public DiagnosticTest {
}
private:
- int index_;
+ FilePath db_path_;
DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest);
};
+// Uniquifier to use the sql::DiagnosticErrorDelegate template which
+// requires a static name() method.
+template <size_t unique>
+class HistogramUniquifier {
+ public:
+ static const char* name() {
+ const char* kHistogramNames[] = {
+ "Sqlite.Cookie.Error",
+ "Sqlite.History.Error",
+ "Sqlite.Thumbnail.Error",
+ "Sqlite.Text.Error",
+ "Sqlite.Web.Error"
+ };
+ return kHistogramNames[unique];
+ }
+};
+
} // namespace
sql::ErrorDelegate* GetErrorHandlerForCookieDb() {
- return new BasicSqliteErrrorHandler<0>();
+ return new sql::DiagnosticErrorDelegate<HistogramUniquifier<0> >();
}
sql::ErrorDelegate* GetErrorHandlerForHistoryDb() {
- return new BasicSqliteErrrorHandler<1>();
+ return new sql::DiagnosticErrorDelegate<HistogramUniquifier<1> >();
}
sql::ErrorDelegate* GetErrorHandlerForThumbnailDb() {
- return new BasicSqliteErrrorHandler<2>();
+ return new sql::DiagnosticErrorDelegate<HistogramUniquifier<2> >();
}
sql::ErrorDelegate* GetErrorHandlerForTextDb() {
- return new BasicSqliteErrrorHandler<3>();
+ return new sql::DiagnosticErrorDelegate<HistogramUniquifier<3> >();
}
sql::ErrorDelegate* GetErrorHandlerForWebDb() {
- return new BasicSqliteErrrorHandler<4>();
+ return new sql::DiagnosticErrorDelegate<HistogramUniquifier<4> >();
}
DiagnosticTest* MakeSqliteWebDbTest() {
- return new SqliteIntegrityTest(0);
+ return new SqliteIntegrityTest(ASCIIToUTF16("Web Database"),
+ FilePath(chrome::kWebDataFilename));
}
DiagnosticTest* MakeSqliteCookiesDbTest() {
- return new SqliteIntegrityTest(1);
+ return new SqliteIntegrityTest(ASCIIToUTF16("Cookies Database"),
+ FilePath(chrome::kCookieFilename));
}
DiagnosticTest* MakeSqliteHistoryDbTest() {
- return new SqliteIntegrityTest(2);
+ return new SqliteIntegrityTest(ASCIIToUTF16("History Database"),
+ FilePath(chrome::kHistoryFilename));
}
DiagnosticTest* MakeSqliteArchivedHistoryDbTest() {
- return new SqliteIntegrityTest(3);
+ return new SqliteIntegrityTest(ASCIIToUTF16("Archived History Database"),
+ FilePath(chrome::kArchivedHistoryFilename));
}
DiagnosticTest* MakeSqliteThumbnailsDbTest() {
- return new SqliteIntegrityTest(4);
+ return new SqliteIntegrityTest(ASCIIToUTF16("Thumbnails Database"),
+ FilePath(chrome::kThumbnailsFilename));
}
+DiagnosticTest* MakeSqliteAppCacheDbTest() {
+ FilePath appcache_dir(chrome::kAppCacheDirname);
+ FilePath appcache_db = appcache_dir.Append(appcache::kAppCacheDatabaseName);
+ return new SqliteIntegrityTest(ASCIIToUTF16("AppCache Database"),
+ appcache_db);
+}
+
+DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() {
+ FilePath databases_dir(webkit_database::kDatabaseDirectoryName);
+ FilePath tracker_db =
+ databases_dir.Append(webkit_database::kTrackerDatabaseFileName);
+ return new SqliteIntegrityTest(ASCIIToUTF16("DatabaseTracker DB"),
+ tracker_db);
+}
diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.h b/chrome/browser/diagnostics/sqlite_diagnostics.h
index 1618a07..c416e88 100644
--- a/chrome/browser/diagnostics/sqlite_diagnostics.h
+++ b/chrome/browser/diagnostics/sqlite_diagnostics.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -25,5 +25,7 @@ DiagnosticTest* MakeSqliteCookiesDbTest();
DiagnosticTest* MakeSqliteHistoryDbTest();
DiagnosticTest* MakeSqliteArchivedHistoryDbTest();
DiagnosticTest* MakeSqliteThumbnailsDbTest();
+DiagnosticTest* MakeSqliteAppCacheDbTest();
+DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest();
#endif // CHROME_BROWSER_DIAGNOSTICS_SQLITE_DIAGNOSTICS_H_