From ba4e52f352826c33876ab2c0ce0686bbe280af4a Mon Sep 17 00:00:00 2001 From: "paulg@google.com" Date: Wed, 29 Oct 2008 00:54:35 +0000 Subject: Fix a minor memory leak. BUG=1340229 Review URL: http://codereview.chromium.org/8690 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4117 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/safe_browsing/safe_browsing_database_bloom.cc | 5 ++--- chrome/browser/safe_browsing/safe_browsing_database_bloom.h | 2 +- chrome/browser/safe_browsing/safe_browsing_database_impl.cc | 5 ++--- chrome/browser/safe_browsing/safe_browsing_database_impl.h | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc index 730b62b..59e9c6c 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc @@ -44,7 +44,6 @@ static const int kMaxStalenessMinutes = 45; SafeBrowsingDatabaseBloom::SafeBrowsingDatabaseBloom() : db_(NULL), init_(false), - chunk_inserted_callback_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(resume_factory_(this)), did_resume_(false) { @@ -87,7 +86,7 @@ bool SafeBrowsingDatabaseBloom::Init(const std::wstring& filename, } init_ = true; - chunk_inserted_callback_ = chunk_inserted_callback; + chunk_inserted_callback_.reset(chunk_inserted_callback); return true; } @@ -405,7 +404,7 @@ void SafeBrowsingDatabaseBloom::InsertChunks(const std::string& list_name, delete chunks; - if (chunk_inserted_callback_) + if (chunk_inserted_callback_.get()) chunk_inserted_callback_->Run(); } diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.h b/chrome/browser/safe_browsing/safe_browsing_database_bloom.h index e470a64..9569a43 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.h +++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.h @@ -203,7 +203,7 @@ class SafeBrowsingDatabaseBloom : public SafeBrowsingDatabase { std::wstring filename_; // Called after an add/sub chunk is processed. - Callback0::Type* chunk_inserted_callback_; + scoped_ptr chunk_inserted_callback_; // Used to schedule resetting the database because of corruption. ScopedRunnableMethodFactory reset_factory_; diff --git a/chrome/browser/safe_browsing/safe_browsing_database_impl.cc b/chrome/browser/safe_browsing/safe_browsing_database_impl.cc index db25ec7..9f47afd 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_impl.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_impl.cc @@ -64,7 +64,6 @@ SafeBrowsingDatabaseImpl::SafeBrowsingDatabaseImpl() transaction_count_(0), init_(false), asynchronous_(true), - chunk_inserted_callback_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(process_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(bloom_read_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(bloom_write_factory_(this)), @@ -109,7 +108,7 @@ bool SafeBrowsingDatabaseImpl::Init(const std::wstring& filename, } init_ = true; - chunk_inserted_callback_ = chunk_inserted_callback; + chunk_inserted_callback_.reset(chunk_inserted_callback); return true; } @@ -543,7 +542,7 @@ bool SafeBrowsingDatabaseImpl::ProcessChunks() { } } - if (chunk_inserted_callback_) + if (chunk_inserted_callback_.get()) chunk_inserted_callback_->Run(); return true; diff --git a/chrome/browser/safe_browsing/safe_browsing_database_impl.h b/chrome/browser/safe_browsing/safe_browsing_database_impl.h index 4c46b75..4b47859 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_impl.h +++ b/chrome/browser/safe_browsing/safe_browsing_database_impl.h @@ -242,7 +242,7 @@ class SafeBrowsingDatabaseImpl : public SafeBrowsingDatabase { std::queue pending_add_del_; // Called after an add/sub chunk is processed. - Callback0::Type* chunk_inserted_callback_; + scoped_ptr chunk_inserted_callback_; // Used to schedule small bits of work when writing to the database. ScopedRunnableMethodFactory process_factory_; -- cgit v1.1