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/net | |
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/net')
-rw-r--r-- | chrome/browser/net/sqlite_persistent_cookie_store.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc index ce371f5..d8ec074 100644 --- a/chrome/browser/net/sqlite_persistent_cookie_store.cc +++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc @@ -281,6 +281,27 @@ static const int kCompatibleVersionNumber = 3; 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 CookieDbSqliteErrrorHandler : public sql::ErrorDelegate { + public: + virtual int OnError(int error, sql::Connection* connection, + sql::Statement* stmt) { + NOTREACHED() << "cookie 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 50 gives them room to grow. + static LinearHistogram histogram("Sqlite.Cookie.Error", 1, 50, 51); + histogram.SetFlags(kUmaTargetedHistogramFlag); + histogram.Add(error); + } +}; + // Initializes the cookies table, returning true on success. bool InitTable(sql::Connection* db) { if (!db->DoesTableExist("cookies")) { @@ -314,6 +335,8 @@ bool SQLitePersistentCookieStore::Load( return false; } + db->set_error_delegate(new CookieDbSqliteErrrorHandler()); + if (!EnsureDatabaseVersion(db.get()) || !InitTable(db.get())) { NOTREACHED() << "Unable to initialize cookie DB."; return false; |