diff options
-rw-r--r-- | chrome/browser/browsing_data_indexed_db_helper.cc | 53 | ||||
-rw-r--r-- | chrome/browser/browsing_data_indexed_db_helper.h | 18 | ||||
-rw-r--r-- | chrome/browser/browsing_data_indexed_db_helper_browsertest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.cc | 9 | ||||
-rw-r--r-- | chrome/browser/mock_browsing_data_indexed_db_helper.cc | 10 | ||||
-rw-r--r-- | chrome/browser/mock_browsing_data_indexed_db_helper.h | 10 |
6 files changed, 61 insertions, 51 deletions
diff --git a/chrome/browser/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data_indexed_db_helper.cc index 19a24ba..e183415 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.cc +++ b/chrome/browser/browsing_data_indexed_db_helper.cc @@ -5,7 +5,8 @@ #include "chrome/browser/browsing_data_indexed_db_helper.h" #include "base/bind.h" -#include "base/callback_old.h" +#include "base/callback.h" +#include "base/compiler_specific.h" #include "base/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" @@ -26,9 +27,10 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { explicit BrowsingDataIndexedDBHelperImpl(Profile* profile); virtual void StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback); - virtual void CancelNotification(); - virtual void DeleteIndexedDB(const GURL& origin); + const base::Callback<void(const std::list<IndexedDBInfo>&)>& + callback) OVERRIDE; + virtual void CancelNotification() OVERRIDE; + virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; private: virtual ~BrowsingDataIndexedDBHelperImpl(); @@ -46,8 +48,8 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { std::list<IndexedDBInfo> indexed_db_info_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > - completion_callback_; + base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_; + // Indicates whether or not we're currently fetching information: // it's true when StartFetching() is called in the UI thread, and it's reset // after we notified the callback in the UI thread. @@ -60,7 +62,6 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { BrowsingDataIndexedDBHelperImpl::BrowsingDataIndexedDBHelperImpl( Profile* profile) : indexed_db_context_(profile->GetWebKitContext()->indexed_db_context()), - completion_callback_(NULL), is_fetching_(false) { DCHECK(indexed_db_context_.get()); } @@ -69,12 +70,13 @@ BrowsingDataIndexedDBHelperImpl::~BrowsingDataIndexedDBHelperImpl() { } void BrowsingDataIndexedDBHelperImpl::StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { + const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); - DCHECK(callback); + DCHECK_EQ(false, callback.is_null()); + is_fetching_ = true; - completion_callback_.reset(callback); + completion_callback_ = callback; BrowserThread::PostTask( BrowserThread::WEBKIT, FROM_HERE, base::Bind( @@ -84,7 +86,7 @@ void BrowsingDataIndexedDBHelperImpl::StartFetching( void BrowsingDataIndexedDBHelperImpl::CancelNotification() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.reset(); + completion_callback_.Reset(); } void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDB( @@ -122,9 +124,9 @@ void BrowsingDataIndexedDBHelperImpl::NotifyInUIThread() { DCHECK(is_fetching_); // Note: completion_callback_ mutates only in the UI thread, so it's safe to // test it here. - if (completion_callback_ != NULL) { - completion_callback_->Run(indexed_db_info_); - completion_callback_.reset(); + if (!completion_callback_.is_null()) { + completion_callback_.Run(indexed_db_info_); + completion_callback_.Reset(); } is_fetching_ = false; } @@ -170,8 +172,7 @@ PendingIndexedDBInfo::~PendingIndexedDBInfo() { } CannedBrowsingDataIndexedDBHelper::CannedBrowsingDataIndexedDBHelper() - : completion_callback_(NULL), - is_fetching_(false) { + : is_fetching_(false) { } CannedBrowsingDataIndexedDBHelper* CannedBrowsingDataIndexedDBHelper::Clone() { @@ -203,12 +204,13 @@ bool CannedBrowsingDataIndexedDBHelper::empty() const { } void CannedBrowsingDataIndexedDBHelper::StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { + const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); - DCHECK(callback); + DCHECK_EQ(false, callback.is_null()); + is_fetching_ = true; - completion_callback_.reset(callback); + completion_callback_ = callback; BrowserThread::PostTask( BrowserThread::WEBKIT, FROM_HERE, base::Bind( @@ -250,16 +252,17 @@ void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() { void CannedBrowsingDataIndexedDBHelper::NotifyInUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - // Note: completion_callback_ mutates only in the UI thread, so it's safe to - // test it here. - if (completion_callback_ != NULL) { - completion_callback_->Run(indexed_db_info_); - completion_callback_.reset(); + + // Completion_callback_ mutates only in the UI thread, so it's safe to test it + // here. + if (!completion_callback_.is_null()) { + completion_callback_.Run(indexed_db_info_); + completion_callback_.Reset(); } is_fetching_ = false; } void CannedBrowsingDataIndexedDBHelper::CancelNotification() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.reset(); + completion_callback_.Reset(); } diff --git a/chrome/browser/browsing_data_indexed_db_helper.h b/chrome/browser/browsing_data_indexed_db_helper.h index 5c5ad44..5d7177e50 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.h +++ b/chrome/browser/browsing_data_indexed_db_helper.h @@ -9,7 +9,8 @@ #include <list> #include <string> -#include "base/callback_old.h" +#include "base/callback.h" +#include "base/compiler_specific.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -54,7 +55,8 @@ class BrowsingDataIndexedDBHelper // callback. // This must be called only in the UI thread. virtual void StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback) = 0; + const base::Callback<void(const std::list<IndexedDBInfo>&)>& + callback) = 0; // Cancels the notification callback (i.e., the window that created it no // longer exists). // This must be called only in the UI thread. @@ -77,7 +79,7 @@ class CannedBrowsingDataIndexedDBHelper // Return a copy of the IndexedDB helper. Only one consumer can use the // StartFetching method at a time, so we need to create a copy of the helper - // everytime we instantiate a cookies tree model for it. + // every time we instantiate a cookies tree model for it. CannedBrowsingDataIndexedDBHelper* Clone(); // Add a indexed database to the set of canned indexed databases that is @@ -93,9 +95,10 @@ class CannedBrowsingDataIndexedDBHelper // BrowsingDataIndexedDBHelper methods. virtual void StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback); - virtual void CancelNotification(); - virtual void DeleteIndexedDB(const GURL& origin) {} + const base::Callback<void(const std::list<IndexedDBInfo>&)>& + callback) OVERRIDE; + virtual void CancelNotification() OVERRIDE; + virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} private: struct PendingIndexedDBInfo { @@ -124,8 +127,7 @@ class CannedBrowsingDataIndexedDBHelper std::list<IndexedDBInfo> indexed_db_info_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > - completion_callback_; + base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_; // Indicates whether or not we're currently fetching information: // it's true when StartFetching() is called in the UI thread, and it's reset diff --git a/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc index 6ddd20c..1aa01ea 100644 --- a/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc +++ b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc @@ -5,7 +5,8 @@ #include <string> #include "base/basictypes.h" -#include "base/callback.h" +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/message_loop.h" @@ -21,8 +22,7 @@ namespace { typedef BrowsingDataHelperCallback<BrowsingDataIndexedDBHelper::IndexedDBInfo> TestCompletionCallback; -class BrowsingDataIndexedDBHelperTest : public InProcessBrowserTest { -}; +typedef InProcessBrowserTest BrowsingDataIndexedDBHelperTest; IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { const GURL origin1("http://host1:1/"); @@ -36,7 +36,8 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { TestCompletionCallback callback; helper->StartFetching( - NewCallback(&callback, &TestCompletionCallback::callback)); + base::Bind(&TestCompletionCallback::callback, + base::Unretained(&callback))); std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = callback.result(); @@ -60,7 +61,8 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) { TestCompletionCallback callback; helper->StartFetching( - NewCallback(&callback, &TestCompletionCallback::callback)); + base::Bind(&TestCompletionCallback::callback, + base::Unretained(&callback))); std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = callback.result(); diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index d1c24d0..1df16c8 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -641,8 +641,8 @@ CookiesTreeModel::CookiesTreeModel( this, &CookiesTreeModel::OnSessionStorageModelInfoLoaded)); } - // TODO(michaeln): when all of the ui impls have been updated, - // make this a required parameter. + // TODO(michaeln): When all of the UI implementations have been updated, make + // this a required parameter. if (appcache_helper_) { appcache_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnAppCacheModelInfoLoaded, @@ -650,8 +650,9 @@ CookiesTreeModel::CookiesTreeModel( } if (indexed_db_helper_) { - indexed_db_helper_->StartFetching(NewCallback( - this, &CookiesTreeModel::OnIndexedDBModelInfoLoaded)); + indexed_db_helper_->StartFetching( + base::Bind(&CookiesTreeModel::OnIndexedDBModelInfoLoaded, + base::Unretained(this))); } if (file_system_helper_) { diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.cc b/chrome/browser/mock_browsing_data_indexed_db_helper.cc index 5f17818..91894f2 100644 --- a/chrome/browser/mock_browsing_data_indexed_db_helper.cc +++ b/chrome/browser/mock_browsing_data_indexed_db_helper.cc @@ -14,12 +14,12 @@ MockBrowsingDataIndexedDBHelper::~MockBrowsingDataIndexedDBHelper() { } void MockBrowsingDataIndexedDBHelper::StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { - callback_.reset(callback); + const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { + callback_ = callback; } void MockBrowsingDataIndexedDBHelper::CancelNotification() { - callback_.reset(NULL); + callback_.Reset(); } void MockBrowsingDataIndexedDBHelper::DeleteIndexedDB( @@ -42,8 +42,8 @@ void MockBrowsingDataIndexedDBHelper::AddIndexedDBSamples() { } void MockBrowsingDataIndexedDBHelper::Notify() { - CHECK(callback_.get()); - callback_->Run(response_); + CHECK_EQ(false, callback_.is_null()); + callback_.Run(response_); } void MockBrowsingDataIndexedDBHelper::Reset() { diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.h b/chrome/browser/mock_browsing_data_indexed_db_helper.h index f047ed4..f4b9dea 100644 --- a/chrome/browser/mock_browsing_data_indexed_db_helper.h +++ b/chrome/browser/mock_browsing_data_indexed_db_helper.h @@ -10,6 +10,7 @@ #include <map> #include "base/callback.h" +#include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/browsing_data_indexed_db_helper.h" @@ -36,14 +37,15 @@ class MockBrowsingDataIndexedDBHelper // BrowsingDataIndexedDBHelper. virtual void StartFetching( - Callback1<const std::list<IndexedDBInfo>& >::Type* callback); - virtual void CancelNotification(); - virtual void DeleteIndexedDB(const GURL& origin); + const base::Callback<void(const std::list<IndexedDBInfo>&)>& + callback) OVERRIDE; + virtual void CancelNotification() OVERRIDE; + virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; private: virtual ~MockBrowsingDataIndexedDBHelper(); - scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > callback_; + base::Callback<void(const std::list<IndexedDBInfo>&)> callback_; std::map<GURL, bool> origins_; std::list<IndexedDBInfo> response_; }; |