Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: sql/connection.h

Issue 11111021: Remove ref counting on sql::ErrorDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as requested Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.cc ('k') | sql/connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.h
diff --git a/sql/connection.h b/sql/connection.h
index 65020a04ebb86e0842f1048d119e2d88185b4fbf..1aef0644932a2ed2c502861a05470791d4b444db 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);
};
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.cc ('k') | sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698