summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 21:45:53 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 21:45:53 +0000
commit7bb70e64214d11bb897c50ed4e5eeeda8de29578 (patch)
tree9492ec8f9eaf2520ef928f784b4b3c727db39cb5
parent194cfcf377509bf977fc0302d3e4a026a95b7e53 (diff)
downloadchromium_src-7bb70e64214d11bb897c50ed4e5eeeda8de29578.zip
chromium_src-7bb70e64214d11bb897c50ed4e5eeeda8de29578.tar.gz
chromium_src-7bb70e64214d11bb897c50ed4e5eeeda8de29578.tar.bz2
Remove last client of sql::DiagnosticErrorDelegate.
In the first pass, there was a problem with histograms. I do not recall what the problem was, so removing things. BUG=none Review URL: https://chromiumcodereview.appspot.com/15104003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201895 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--sql/diagnostic_error_delegate.h38
-rw-r--r--sql/error_delegate_util.h23
-rw-r--r--sql/sql.gyp1
-rw-r--r--webkit/dom_storage/dom_storage_database.cc22
4 files changed, 13 insertions, 71 deletions
diff --git a/sql/diagnostic_error_delegate.h b/sql/diagnostic_error_delegate.h
deleted file mode 100644
index 78b3d9d..0000000
--- a/sql/diagnostic_error_delegate.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2012 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 SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
-#define SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
-
-#include "base/logging.h"
-#include "sql/connection.h"
-#include "sql/error_delegate_util.h"
-#include "sql/sql_export.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.
-// See error_delegate_util.h for an explanation as to why this class is a
-// template.
-template <class UniqueT>
-class DiagnosticErrorDelegate : public ErrorDelegate {
- public:
- DiagnosticErrorDelegate() {}
- virtual ~DiagnosticErrorDelegate() {}
-
- virtual int OnError(int error, Connection* connection,
- Statement* stmt) {
- LogAndRecordErrorInHistogram<UniqueT>(error, connection);
- return error;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DiagnosticErrorDelegate);
-};
-
-} // namespace sql
-
-#endif // SQL_DIAGNOSTIC_ERROR_DELEGATE_H_
diff --git a/sql/error_delegate_util.h b/sql/error_delegate_util.h
index 6b90ccf..0c67c07 100644
--- a/sql/error_delegate_util.h
+++ b/sql/error_delegate_util.h
@@ -5,8 +5,6 @@
#ifndef SQL_ERROR_DELEGATE_UTIL_H_
#define SQL_ERROR_DELEGATE_UTIL_H_
-#include "base/metrics/histogram.h"
-#include "sql/connection.h"
#include "sql/sql_export.h"
namespace sql {
@@ -15,27 +13,6 @@ namespace sql {
// |error|.
SQL_EXPORT bool IsErrorCatastrophic(int error);
-// Log error in console in debug mode and generate a UMA histogram in release
-// mode for |error| for |UniqueT::name()|.
-// This function is templated because histograms need to be singletons. That is
-// why they are always static at the function scope. The template parameter
-// makes the compiler create unique functions that don't share the same static
-// variable.
-template <class UniqueT>
-void LogAndRecordErrorInHistogram(int error,
- sql::Connection* connection) {
- LOG(ERROR) << "sqlite error " << error
- << ", errno " << connection->GetLastErrno()
- << ": " << connection->GetErrorMessage();
-
- // Trim off the extended error codes.
- error &= 0xff;
-
- // The histogram values from sqlite result codes currently go from 1 to 26
- // but 50 gives them room to grow.
- UMA_HISTOGRAM_ENUMERATION(UniqueT::name(), error, 50);
-}
-
} // namespace sql
#endif // SQL_ERROR_DELEGATE_UTIL_H_
diff --git a/sql/sql.gyp b/sql/sql.gyp
index 0d8f8be..86cfbc9 100644
--- a/sql/sql.gyp
+++ b/sql/sql.gyp
@@ -18,7 +18,6 @@
'sources': [
'connection.cc',
'connection.h',
- 'diagnostic_error_delegate.h',
'error_delegate_util.cc',
'error_delegate_util.h',
'init_status.h',
diff --git a/webkit/dom_storage/dom_storage_database.cc b/webkit/dom_storage/dom_storage_database.cc
index 85f4218..4994d87 100644
--- a/webkit/dom_storage/dom_storage_database.cc
+++ b/webkit/dom_storage/dom_storage_database.cc
@@ -4,9 +4,9 @@
#include "webkit/dom_storage/dom_storage_database.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/logging.h"
-#include "sql/diagnostic_error_delegate.h"
#include "sql/statement.h"
#include "sql/transaction.h"
#include "third_party/sqlite/sqlite3.h"
@@ -15,13 +15,16 @@ namespace {
const base::FilePath::CharType kJournal[] = FILE_PATH_LITERAL("-journal");
-class HistogramUniquifier {
- public:
- static const char* name() { return "Sqlite.DomStorageDatabase.Error"; }
-};
-
-sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() {
- return new sql::DiagnosticErrorDelegate<HistogramUniquifier>();
+void DatabaseErrorCallback(int error, sql::Statement* stmt) {
+ // Without a callback to ignore errors,
+ // DomStorageDatabaseTest.TestCanOpenFileThatIsNotADatabase fails with:
+ // ERROR:connection.cc(735)] sqlite error 522, errno 0: disk I/O error
+ // FATAL:connection.cc(750)] disk I/O error
+ // <backtrace>
+ // <crash>
+ //
+ // TODO(shess): If/when infrastructure lands which can allow tests
+ // to handle SQLite errors appropriately, remove this.
}
} // anon namespace
@@ -159,7 +162,8 @@ bool DomStorageDatabase::LazyOpen(bool create_if_needed) {
}
db_.reset(new sql::Connection());
- db_->set_error_delegate(GetErrorHandlerForDomStorageDatabase());
+ db_->set_histogram_tag("DomStorageDatabase");
+ db_->set_error_callback(base::Bind(&DatabaseErrorCallback));
if (file_path_.empty()) {
// This code path should only be triggered by unit tests.