summaryrefslogtreecommitdiffstats
path: root/app/sql
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 /app/sql
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 'app/sql')
-rw-r--r--app/sql/diagnostic_error_delegate.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/sql/diagnostic_error_delegate.h b/app/sql/diagnostic_error_delegate.h
new file mode 100644
index 0000000..e62bba2
--- /dev/null
+++ b/app/sql/diagnostic_error_delegate.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef APP_SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
+#define APP_SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
+
+#include "app/sql/connection.h"
+#include "base/histogram.h"
+#include "base/logging.h"
+
+namespace sql {
+
+// 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 <class UniqueT>
+class DiagnosticErrorDelegate : public ErrorDelegate {
+ public:
+
+ virtual int OnError(int error, Connection* connection,
+ 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(UniqueT::name(), error, 50);
+ }
+};
+
+} // namespace sql
+
+#endif // APP_SQL_DIAGNOSTIC_ERROR_DELEGATE_H_