summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-17 08:39:46 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-17 08:39:46 +0000
commitc3881b37c9dba1b0e72c586ba9ec5f411bb407c0 (patch)
treeaa5c179c244a1be3322318e5e0e0299fb5d69251 /sql/connection.h
parent6d595ee53cc83225b1d62dc591abe78eb9492ce9 (diff)
downloadchromium_src-c3881b37c9dba1b0e72c586ba9ec5f411bb407c0.zip
chromium_src-c3881b37c9dba1b0e72c586ba9ec5f411bb407c0.tar.gz
chromium_src-c3881b37c9dba1b0e72c586ba9ec5f411bb407c0.tar.bz2
Dump additional error info for thumbnail database.
The union of SQLite error messages and platform errno is a potentially large space which may not be reasonable to histogram. Instead, randomly dump a crash report with diagnostic information which can be correlated with histograms. BUG=240396 Review URL: https://chromiumcodereview.appspot.com/15131008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.h')
-rw-r--r--sql/connection.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/sql/connection.h b/sql/connection.h
index 44b97f6..96312c4 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -10,6 +10,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -138,10 +139,32 @@ class SQL_EXPORT Connection {
// This must be called before Open() to have an effect.
void set_exclusive_locking() { exclusive_locking_ = true; }
+ // Set an error-handling callback. On errors, the error number (and
+ // statement, if available) will be passed to the callback.
+ //
+ // If no callback is set, the default action is to crash in debug
+ // mode or return failure in release mode.
+ //
+ // TODO(shess): ErrorDelegate allowed for returning a different
+ // error. Determine if this is necessary for the callback. In my
+ // experience, this is not well-tested and probably not safe, and
+ // current clients always return the same error passed.
+ // Additionally, most errors don't admit to a clean way to retry the
+ // failed operation, so converting an error to SQLITE_OK is probably
+ // not feasible.
+ typedef base::Callback<void(int, Statement*)> ErrorCallback;
+ void set_error_callback(const ErrorCallback& callback) {
+ error_callback_ = callback;
+ }
+ void reset_error_callback() {
+ error_callback_.Reset();
+ }
+
// Sets the object that will handle errors. Recomended that it should be set
// before calling Open(). If not set, the default is to ignore errors on
// release and assert on debug builds.
// Takes ownership of |delegate|.
+ // NOTE(shess): Deprecated, use set_error_callback().
void set_error_delegate(ErrorDelegate* delegate) {
error_delegate_.reset(delegate);
}
@@ -497,6 +520,8 @@ class SQL_EXPORT Connection {
// databases.
bool poisoned_;
+ ErrorCallback error_callback_;
+
// This object handles errors resulting from all forms of executing sqlite
// commands or statements. It can be null which means default handling.
scoped_ptr<ErrorDelegate> error_delegate_;