| 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
|
|
|