diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 00:44:16 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 00:44:16 +0000 |
commit | 3f1828a7c18c45910d5ea938fe476d1a60bb272c (patch) | |
tree | 64d9ae41fe69c09512b0abafafe301593a9eafd6 /chrome/browser/history/text_database.cc | |
parent | 6fc696d8526419f8cec0897e76c25a16b74b47de (diff) | |
download | chromium_src-3f1828a7c18c45910d5ea938fe476d1a60bb272c.zip chromium_src-3f1828a7c18c45910d5ea938fe476d1a60bb272c.tar.gz chromium_src-3f1828a7c18c45910d5ea938fe476d1a60bb272c.tar.bz2 |
Add UMA histograms for sqlite errors
- cookies
- history db
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/243055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/text_database.cc')
-rw-r--r-- | chrome/browser/history/text_database.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc index d56788ca..e9b37eb 100644 --- a/chrome/browser/history/text_database.cc +++ b/chrome/browser/history/text_database.cc @@ -11,6 +11,7 @@ #include "app/sql/statement.h" #include "app/sql/transaction.h" #include "base/file_util.h" +#include "base/histogram.h" #include "base/logging.h" #include "base/string_util.h" @@ -54,6 +55,27 @@ 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) @@ -116,6 +138,9 @@ bool TextDatabase::Init() { return false; } + // Set the exceptional sqlite error handler. + db_.set_error_delegate(new TextDbSqliteErrrorHandler()); + // 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 |