summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 17:41:16 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 17:41:16 +0000
commit49dc4f20a2655ac42cd4a2902faf88ccf61aee7f (patch)
tree9f65b7557b613a72fe6305ea4e9c188893f47c15 /sql/connection.h
parent494885e17887147c9ee61d02b5827dd1d2268926 (diff)
downloadchromium_src-49dc4f20a2655ac42cd4a2902faf88ccf61aee7f.zip
chromium_src-49dc4f20a2655ac42cd4a2902faf88ccf61aee7f.tar.gz
chromium_src-49dc4f20a2655ac42cd4a2902faf88ccf61aee7f.tar.bz2
Remove ref counting on sql::ErrorDelegate
BUG=151841 Test=None R=shess TBR=jamesr,erikwright Review URL: https://chromiumcodereview.appspot.com/11111021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.h')
-rw-r--r--sql/connection.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/sql/connection.h b/sql/connection.h
index 65020a0..1aef064 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
#include "sql/sql_export.h"
@@ -78,9 +79,9 @@ class Connection;
// the OnError() callback.
// The tipical usage is to centralize the code designed to handle database
// corruption, low-level IO errors or locking violations.
-class SQL_EXPORT ErrorDelegate : public base::RefCounted<ErrorDelegate> {
+class SQL_EXPORT ErrorDelegate {
public:
- ErrorDelegate();
+ virtual ~ErrorDelegate();
// |error| is an sqlite result code as seen in sqlite\preprocessed\sqlite3.h
// |connection| is db connection where the error happened and |stmt| is
@@ -94,11 +95,6 @@ class SQL_EXPORT ErrorDelegate : public base::RefCounted<ErrorDelegate> {
// re-tried then returning SQLITE_OK is appropiate; otherwise is recomended
// that you return the original |error| or the appropiae error code.
virtual int OnError(int error, Connection* connection, Statement* stmt) = 0;
-
- protected:
- friend class base::RefCounted<ErrorDelegate>;
-
- virtual ~ErrorDelegate();
};
class SQL_EXPORT Connection {
@@ -142,8 +138,9 @@ class SQL_EXPORT Connection {
// 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|.
void set_error_delegate(ErrorDelegate* delegate) {
- error_delegate_ = delegate;
+ error_delegate_.reset(delegate);
}
// Initialization ------------------------------------------------------------
@@ -445,7 +442,7 @@ class SQL_EXPORT Connection {
// This object handles errors resulting from all forms of executing sqlite
// commands or statements. It can be null which means default handling.
- scoped_refptr<ErrorDelegate> error_delegate_;
+ scoped_ptr<ErrorDelegate> error_delegate_;
DISALLOW_COPY_AND_ASSIGN(Connection);
};