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

Unified Diff: chrome/browser/net/sqlite_persistent_cookie_store.cc

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 | « no previous file | sql/connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/sqlite_persistent_cookie_store.cc
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc
index 10e315328e680804d9c8884a19952b4fde14f7e3..f9795745bbf3c2627c2784b7d1a58f23abfbb242 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc
@@ -75,8 +75,6 @@ class SQLitePersistentCookieStore::Backend
num_cookies_read_(0),
num_priority_waiting_(0),
total_priority_requests_(0) {
- error_delegate_ =
- new KillDatabaseErrorDelegate(this, GetErrorHandlerForCookieDb());
}
// Creates or loads the SQLite database.
@@ -111,35 +109,26 @@ class SQLitePersistentCookieStore::Backend
public:
KillDatabaseErrorDelegate(Backend* backend,
sql::ErrorDelegate* wrapped_delegate);
+
+ virtual ~KillDatabaseErrorDelegate() {}
+
// ErrorDelegate implementation.
virtual int OnError(int error,
sql::Connection* connection,
sql::Statement* stmt) OVERRIDE;
- void reset_backend() {
- backend_ = NULL;
- }
-
- protected:
- virtual ~KillDatabaseErrorDelegate() {}
-
private:
// Do not increment the count on Backend, as that would create a circular
- // reference (Backend -> Connection -> ErrorDelegate -> Backend). Instead,
- // Backend will call reset_backend() when it is going away.
+ // reference (Backend -> Connection -> ErrorDelegate -> Backend).
Backend* backend_;
- scoped_refptr<sql::ErrorDelegate> wrapped_delegate_;
+ scoped_ptr<sql::ErrorDelegate> wrapped_delegate_;
DISALLOW_COPY_AND_ASSIGN(KillDatabaseErrorDelegate);
};
// You should call Close() before destructing this object.
~Backend() {
- if (error_delegate_.get()) {
- error_delegate_->reset_backend();
- error_delegate_ = NULL;
- }
DCHECK(!db_.get()) << "Close should have already been called.";
DCHECK(num_pending_ == 0 && pending_.empty());
}
@@ -227,7 +216,6 @@ class SQLitePersistentCookieStore::Backend
FilePath path_;
scoped_ptr<sql::Connection> db_;
- scoped_refptr<KillDatabaseErrorDelegate> error_delegate_;
sql::MetaTable meta_table_;
typedef std::list<PendingOperation*> PendingOperationsList;
@@ -371,10 +359,9 @@ int SQLitePersistentCookieStore::Backend::KillDatabaseErrorDelegate::OnError(
MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&Backend::KillDatabase, backend_));
- // Avoid being called more than once. There should still be a reference to
- // this ErrorDelegate in the backend, but just in case don't refer to any
- // members from here forward.
- connection->set_error_delegate(wrapped_delegate_.get());
+ // Avoid being called more than once. This will destroy the
+ // KillDatabaseErrorDelegate. Do not refer to any members from here forward.
+ connection->set_error_delegate(wrapped_delegate_.release());
}
return error;
@@ -627,7 +614,8 @@ bool SQLitePersistentCookieStore::Backend::InitializeDatabase() {
}
db_.reset(new sql::Connection);
- db_->set_error_delegate(error_delegate_.get());
+ db_->set_error_delegate(
+ new KillDatabaseErrorDelegate(this, GetErrorHandlerForCookieDb()));
if (!db_->Open(path_)) {
NOTREACHED() << "Unable to open cookie DB.";
« no previous file with comments | « no previous file | sql/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698