diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 00:56:41 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 00:56:41 +0000 |
commit | ed655b77ca7f838078b20ca030c8456818eafe70 (patch) | |
tree | 8d1e92706f0e556a4a280c2b9195a52f837fa678 /chrome/browser/history | |
parent | 4a00221ac7fab87ea4da95af07f079c650694806 (diff) | |
download | chromium_src-ed655b77ca7f838078b20ca030c8456818eafe70.zip chromium_src-ed655b77ca7f838078b20ca030c8456818eafe70.tar.gz chromium_src-ed655b77ca7f838078b20ca030c8456818eafe70.tar.bz2 |
Move the sqlite error handler to a single location
- Eliminate code duplication
- Cover other 3 databases
- Still doing the same as before, sending UMA histograms
BUG=11908
TEST=none
Review URL: http://codereview.chromium.org/270101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29073 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/history_database.cc | 4 | ||||
-rw-r--r-- | chrome/browser/history/text_database.cc | 24 | ||||
-rw-r--r-- | chrome/browser/history/thumbnail_database.cc | 4 |
3 files changed, 10 insertions, 22 deletions
diff --git a/chrome/browser/history/history_database.cc b/chrome/browser/history/history_database.cc index ee0b179..87367a4 100644 --- a/chrome/browser/history/history_database.cc +++ b/chrome/browser/history/history_database.cc @@ -13,6 +13,7 @@ #include "base/histogram.h" #include "base/rand_util.h" #include "base/string_util.h" +#include "chrome/browser/diagnostics/sqlite_diagnostics.h" namespace history { @@ -59,6 +60,9 @@ HistoryDatabase::~HistoryDatabase() { InitStatus HistoryDatabase::Init(const FilePath& history_name, const FilePath& bookmarks_path) { + // Set the exceptional sqlite error handler. + db_.set_error_delegate(GetErrorHandlerForHistoryDb()); + // Set the database page size to something a little larger to give us // better performance (we're typically seek rather than bandwidth limited). // This only has an effect before any tables have been created, otherwise diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc index fa46853..27d8e6b 100644 --- a/chrome/browser/history/text_database.cc +++ b/chrome/browser/history/text_database.cc @@ -14,6 +14,7 @@ #include "base/histogram.h" #include "base/logging.h" #include "base/string_util.h" +#include "chrome/browser/diagnostics/sqlite_diagnostics.h" // There are two tables in each database, one full-text search (FTS) table which // indexes the contents and title of the pages. The other is a regular SQLITE @@ -53,27 +54,6 @@ const FilePath::CharType kFilePrefix[] = FILE_PATH_LITERAL("History Index "); } // namespace -// 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. -class TextDbSqliteErrrorHandler : public sql::ErrorDelegate { - public: - virtual int OnError(int error, sql::Connection* connection, - sql::Statement* stmt) { - NOTREACHED() << "history db 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 100 gives them room to grow. - static LinearHistogram histogram("Sqlite.History.Error", 1, 50, 51); - histogram.SetFlags(kUmaTargetedHistogramFlag); - histogram.Add(error); - } -}; - TextDatabase::TextDatabase(const FilePath& path, DBIdent id, bool allow_create) @@ -137,7 +117,7 @@ bool TextDatabase::Init() { } // Set the exceptional sqlite error handler. - db_.set_error_delegate(new TextDbSqliteErrrorHandler()); + db_.set_error_delegate(GetErrorHandlerForTextDb()); // Set the database page size to something a little larger to give us // better performance (we're typically seek rather than bandwidth limited). diff --git a/chrome/browser/history/thumbnail_database.cc b/chrome/browser/history/thumbnail_database.cc index ac06464..96aebf7 100644 --- a/chrome/browser/history/thumbnail_database.cc +++ b/chrome/browser/history/thumbnail_database.cc @@ -10,6 +10,7 @@ #include "base/file_util.h" #include "base/time.h" #include "base/string_util.h" +#include "chrome/browser/diagnostics/sqlite_diagnostics.h" #include "chrome/browser/history/history_publisher.h" #include "chrome/browser/history/url_database.h" #include "chrome/common/thumbnail_score.h" @@ -32,6 +33,9 @@ InitStatus ThumbnailDatabase::Init(const FilePath& db_name, const HistoryPublisher* history_publisher) { history_publisher_ = history_publisher; + // Set the exceptional sqlite error handler. + db_.set_error_delegate(GetErrorHandlerForThumbnailDb()); + // Set the database page size to something larger to give us // better performance (we're typically seek rather than bandwidth limited). // This only has an effect before any tables have been created, otherwise |