summaryrefslogtreecommitdiffstats
path: root/chrome/common/sqlite_utils.h
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 21:16:39 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 21:16:39 +0000
commitabbc672ea19a37009560f198ae43f43b72d81874 (patch)
treeb4e0f238468545a28412ec0a28ad4d201751a1bb /chrome/common/sqlite_utils.h
parent4d5ae3782302f6a9a844ae64c7527c4110cf7688 (diff)
downloadchromium_src-abbc672ea19a37009560f198ae43f43b72d81874.zip
chromium_src-abbc672ea19a37009560f198ae43f43b72d81874.tar.gz
chromium_src-abbc672ea19a37009560f198ae43f43b72d81874.tar.bz2
Detect error codes in sqlite calls (one)
- This CL is the skeleton of the approach, does not change current behavior - Right now only detects errors for the SQLStatement::step calls TEST=none BUG=11908 Review URL: http://codereview.chromium.org/174090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/sqlite_utils.h')
-rw-r--r--chrome/common/sqlite_utils.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/chrome/common/sqlite_utils.h b/chrome/common/sqlite_utils.h
index 5ea8655..615708f 100644
--- a/chrome/common/sqlite_utils.h
+++ b/chrome/common/sqlite_utils.h
@@ -28,6 +28,31 @@ class scoped_sqlite3_stmt_ptr;
class SQLStatement;
//------------------------------------------------------------------------------
+// Interface to be implemented by objects that can handle exceptional sqlite
+// conditions. This way client code can focus on handling normal condtions.
+//------------------------------------------------------------------------------
+class SQLErrorHandler {
+ public:
+ virtual ~SQLErrorHandler() {}
+ // Handle a sqlite error. |error| is the return code an of sqlite operation
+ // which is considered an error. This handler is free to try repair, notify
+ // someone or even break into the debugger depending on the situation.
+ virtual int HandleError(int error, sqlite3* db) = 0;
+ // Returns the last value of |error| passed to HandleError.
+ virtual int GetLastError() const = 0;
+};
+
+//------------------------------------------------------------------------------
+// The factory interface is used to create the different error handling
+// strategies for debug, release and for diagnostic mode.
+//------------------------------------------------------------------------------
+class SQLErrorHandlerFactory {
+ public:
+ virtual ~SQLErrorHandlerFactory() {}
+ virtual SQLErrorHandler* Make() = 0;
+};
+
+//------------------------------------------------------------------------------
// A wrapper for sqlite transactions that rollsback when the wrapper
// goes out of scope if the caller has not already called Commit or Rollback.
// Note: the constructor does NOT Begin a transaction.