Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: sql/diagnostic_error_delegate.h

Issue 11141012: Move ErrorDelegate to its own file and add static utility functions to ErrorDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/connection.h ('k') | sql/error_delegate_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/diagnostic_error_delegate.h
diff --git a/sql/diagnostic_error_delegate.h b/sql/diagnostic_error_delegate.h
index 4b8ce323018a158e6b42ed6eebedaeb78d7b18a4..78b3d9d8155217adbec54abb9e135d080c95d684 100644
--- a/sql/diagnostic_error_delegate.h
+++ b/sql/diagnostic_error_delegate.h
@@ -6,8 +6,8 @@
#define SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
#include "base/logging.h"
-#include "base/metrics/histogram.h"
#include "sql/connection.h"
+#include "sql/error_delegate_util.h"
#include "sql/sql_export.h"
namespace sql {
@@ -15,12 +15,8 @@ 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.
+// See error_delegate_util.h for an explanation as to why this class is a
+// template.
template <class UniqueT>
class DiagnosticErrorDelegate : public ErrorDelegate {
public:
@@ -29,24 +25,12 @@ class DiagnosticErrorDelegate : public ErrorDelegate {
virtual int OnError(int error, Connection* connection,
Statement* stmt) {
- LOG(ERROR) << "sqlite error " << error
- << ", errno " << connection->GetLastErrno()
- << ": " << connection->GetErrorMessage();
- RecordErrorInHistogram(error);
+ LogAndRecordErrorInHistogram<UniqueT>(error, connection);
return error;
}
private:
- static void RecordErrorInHistogram(int error) {
- // Trim off the extended error codes.
- error &= 0xff;
-
- // 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);
- }
-
- DISALLOW_COPY_AND_ASSIGN(DiagnosticErrorDelegate);
+ DISALLOW_COPY_AND_ASSIGN(DiagnosticErrorDelegate);
};
} // namespace sql
« no previous file with comments | « sql/connection.h ('k') | sql/error_delegate_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698