summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 22:18:10 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 22:18:10 +0000
commit4350e321e41d0faa025ac516aad6365bc8e9a83f (patch)
tree23d66544bf4dc0f62a20820f66ad2264b2323eee /sql/connection.h
parent90392f8e3110e58c0367c4d87caa7f33709bff6c (diff)
downloadchromium_src-4350e321e41d0faa025ac516aad6365bc8e9a83f.zip
chromium_src-4350e321e41d0faa025ac516aad6365bc8e9a83f.tar.gz
chromium_src-4350e321e41d0faa025ac516aad6365bc8e9a83f.tar.bz2
[sql] Framework for allowing tests to handle errors.
sql/ throws FATAL whenever it sees inappropriate calls, which makes production code to handle errors hard to test. ScopedErrorIgnorer provides a way for tests to signal that specific errors are expected and will be handled. As a first pass, code up some additional tests for some Raze() edge cases, and modify things to pass those tests. BUG=159490 Review URL: https://chromiumcodereview.appspot.com/16664005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.h')
-rw-r--r--sql/connection.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/connection.h b/sql/connection.h
index 8db794d..91139ce 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -335,6 +335,9 @@ class SQL_EXPORT Connection {
const char* GetErrorMessage() const;
private:
+ // Allow test-support code to set/reset error ignorer.
+ friend class ScopedErrorIgnorer;
+
// Statement accesses StatementRef which we don't want to expose to everybody
// (they should go through Statement).
friend class Statement;
@@ -359,6 +362,14 @@ class SQL_EXPORT Connection {
// Internal helper for DoesTableExist and DoesIndexExist.
bool DoesTableOrIndexExist(const char* name, const char* type) const;
+ // Accessors for global error-ignorer, for injecting behavior during tests.
+ // See test/scoped_error_ignorer.h.
+ typedef base::Callback<bool(int)> ErrorIgnorerCallback;
+ static ErrorIgnorerCallback* current_ignorer_cb_;
+ static bool ShouldIgnore(int error);
+ static void SetErrorIgnorer(ErrorIgnorerCallback* ignorer);
+ static void ResetErrorIgnorer();
+
// A StatementRef is a refcounted wrapper around a sqlite statement pointer.
// Refcounting allows us to give these statements out to sql::Statement
// objects while also optionally maintaining a cache of compiled statements