summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 06:17:13 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 06:17:13 +0000
commit91b06c06d2aec6a38a408d97a7991ea4a233d0f6 (patch)
tree1a2c42647eb55cd59995faecb0397e134a04c428
parent3e2dd4fa0baff84af0a1c821328b4b17d128717e (diff)
downloadchromium_src-91b06c06d2aec6a38a408d97a7991ea4a233d0f6.zip
chromium_src-91b06c06d2aec6a38a408d97a7991ea4a233d0f6.tar.gz
chromium_src-91b06c06d2aec6a38a408d97a7991ea4a233d0f6.tar.bz2
base::Bind: Convert BrowsingDataQuotaHelper::StartFetching.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8401027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109382 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browsing_data_quota_helper.h6
-rw-r--r--chrome/browser/browsing_data_quota_helper_impl.cc17
-rw-r--r--chrome/browser/browsing_data_quota_helper_impl.h5
-rw-r--r--chrome/browser/browsing_data_quota_helper_unittest.cc10
-rw-r--r--chrome/browser/cookies_tree_model.cc6
-rw-r--r--chrome/browser/mock_browsing_data_quota_helper.cc12
-rw-r--r--chrome/browser/mock_browsing_data_quota_helper.h5
7 files changed, 30 insertions, 31 deletions
diff --git a/chrome/browser/browsing_data_quota_helper.h b/chrome/browser/browsing_data_quota_helper.h
index 52bf17a..53cc4a2 100644
--- a/chrome/browser/browsing_data_quota_helper.h
+++ b/chrome/browser/browsing_data_quota_helper.h
@@ -9,7 +9,7 @@
#include <list>
#include <string>
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop_proxy.h"
#include "base/time.h"
@@ -58,11 +58,11 @@ class BrowsingDataQuotaHelper
};
typedef std::list<QuotaInfo> QuotaInfoArray;
- typedef Callback1<const QuotaInfoArray&>::Type FetchResultCallback;
+ typedef base::Callback<void(const QuotaInfoArray&)> FetchResultCallback;
static BrowsingDataQuotaHelper* Create(Profile* profile);
- virtual void StartFetching(FetchResultCallback* callback) = 0;
+ virtual void StartFetching(const FetchResultCallback& callback) = 0;
virtual void CancelNotification() = 0;
virtual void RevokeHostQuota(const std::string& host) = 0;
diff --git a/chrome/browser/browsing_data_quota_helper_impl.cc b/chrome/browser/browsing_data_quota_helper_impl.cc
index 4777e66..b198068 100644
--- a/chrome/browser/browsing_data_quota_helper_impl.cc
+++ b/chrome/browser/browsing_data_quota_helper_impl.cc
@@ -22,11 +22,12 @@ BrowsingDataQuotaHelper* BrowsingDataQuotaHelper::Create(Profile* profile) {
profile->GetQuotaManager());
}
-void BrowsingDataQuotaHelperImpl::StartFetching(FetchResultCallback* callback) {
- DCHECK(callback);
- DCHECK(!callback_.get());
+void BrowsingDataQuotaHelperImpl::StartFetching(
+ const FetchResultCallback& callback) {
+ DCHECK_EQ(false, callback.is_null());
+ DCHECK(callback_.is_null());
DCHECK(!is_fetching_);
- callback_.reset(callback);
+ callback_ = callback;
quota_info_.clear();
is_fetching_ = true;
@@ -34,7 +35,7 @@ void BrowsingDataQuotaHelperImpl::StartFetching(FetchResultCallback* callback) {
}
void BrowsingDataQuotaHelperImpl::CancelNotification() {
- callback_.reset();
+ callback_.Reset();
}
void BrowsingDataQuotaHelperImpl::RevokeHostQuota(const std::string& host) {
@@ -143,7 +144,7 @@ void BrowsingDataQuotaHelperImpl::GotHostUsage(const std::string& host,
void BrowsingDataQuotaHelperImpl::OnComplete() {
// Check if CancelNotification was called
- if (!callback_.get())
+ if (callback_.is_null())
return;
if (!ui_thread_->BelongsToCurrentThread()) {
@@ -170,8 +171,8 @@ void BrowsingDataQuotaHelperImpl::OnComplete() {
result.push_back(*info);
}
- callback_->Run(result);
- callback_.reset();
+ callback_.Run(result);
+ callback_.Reset();
}
void BrowsingDataQuotaHelperImpl::DidRevokeHostQuota(
diff --git a/chrome/browser/browsing_data_quota_helper_impl.h b/chrome/browser/browsing_data_quota_helper_impl.h
index 81e2fe7..83b4629 100644
--- a/chrome/browser/browsing_data_quota_helper_impl.h
+++ b/chrome/browser/browsing_data_quota_helper_impl.h
@@ -12,6 +12,7 @@
#include <utility>
#include "base/callback_old.h"
+#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
@@ -29,7 +30,7 @@ class QuotaManager;
// IO thread, we have to communicate over thread using PostTask.
class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
public:
- virtual void StartFetching(FetchResultCallback* callback) OVERRIDE;
+ virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE;
virtual void CancelNotification() OVERRIDE;
virtual void RevokeHostQuota(const std::string& host) OVERRIDE;
@@ -59,7 +60,7 @@ class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
int64 quota);
scoped_refptr<quota::QuotaManager> quota_manager_;
- scoped_ptr<FetchResultCallback> callback_;
+ FetchResultCallback callback_;
typedef std::set<std::pair<std::string, quota::StorageType> > PendingHosts;
PendingHosts pending_hosts_;
diff --git a/chrome/browser/browsing_data_quota_helper_unittest.cc b/chrome/browser/browsing_data_quota_helper_unittest.cc
index 032ff60..ea92abc 100644
--- a/chrome/browser/browsing_data_quota_helper_unittest.cc
+++ b/chrome/browser/browsing_data_quota_helper_unittest.cc
@@ -5,7 +5,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/bind.h"
-#include "base/memory/scoped_callback_factory.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/browsing_data_quota_helper_impl.h"
@@ -26,8 +26,7 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
io_thread_(BrowserThread::IO, &message_loop_),
fetching_completed_(true),
quota_(-1),
- weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
virtual ~BrowsingDataQuotaHelperTest() {}
@@ -63,8 +62,8 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
void StartFetching() {
fetching_completed_ = false;
helper_->StartFetching(
- callback_factory_.NewCallback(
- &BrowsingDataQuotaHelperTest::FetchCompleted));
+ base::Bind(&BrowsingDataQuotaHelperTest::FetchCompleted,
+ weak_factory_.GetWeakPtr()));
}
void RegisterClient(const quota::MockOriginData* data, std::size_t data_len) {
@@ -127,7 +126,6 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
QuotaInfoArray quota_info_;
int64 quota_;
base::WeakPtrFactory<BrowsingDataQuotaHelperTest> weak_factory_;
- base::ScopedCallbackFactory<BrowsingDataQuotaHelperTest> callback_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest);
};
diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc
index 03c220f..3b02deb 100644
--- a/chrome/browser/cookies_tree_model.cc
+++ b/chrome/browser/cookies_tree_model.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/callback.h"
#include "base/memory/linked_ptr.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -668,8 +667,9 @@ CookiesTreeModel::CookiesTreeModel(
}
if (quota_helper_) {
- quota_helper_->StartFetching(NewCallback(
- this, &CookiesTreeModel::OnQuotaModelInfoLoaded));
+ quota_helper_->StartFetching(
+ base::Bind(&CookiesTreeModel::OnQuotaModelInfoLoaded,
+ base::Unretained(this)));
}
}
diff --git a/chrome/browser/mock_browsing_data_quota_helper.cc b/chrome/browser/mock_browsing_data_quota_helper.cc
index c032773..82d879c 100644
--- a/chrome/browser/mock_browsing_data_quota_helper.cc
+++ b/chrome/browser/mock_browsing_data_quota_helper.cc
@@ -13,12 +13,12 @@ MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile)
MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {}
void MockBrowsingDataQuotaHelper::StartFetching(
- FetchResultCallback* callback) {
- callback_.reset(callback);
+ const FetchResultCallback& callback) {
+ callback_ = callback;
}
void MockBrowsingDataQuotaHelper::CancelNotification() {
- callback_.reset(NULL);
+ callback_.Reset();
}
void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) {
@@ -40,8 +40,8 @@ void MockBrowsingDataQuotaHelper::AddQuotaSamples() {
}
void MockBrowsingDataQuotaHelper::Notify() {
- CHECK(callback_.get());
- callback_->Run(response_);
- callback_.reset();
+ CHECK_EQ(false, callback_.is_null());
+ callback_.Run(response_);
+ callback_.Reset();
response_.clear();
}
diff --git a/chrome/browser/mock_browsing_data_quota_helper.h b/chrome/browser/mock_browsing_data_quota_helper.h
index 4c8f778..10dd05e 100644
--- a/chrome/browser/mock_browsing_data_quota_helper.h
+++ b/chrome/browser/mock_browsing_data_quota_helper.h
@@ -10,14 +10,13 @@
#include <string>
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browsing_data_quota_helper.h"
class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper {
public:
explicit MockBrowsingDataQuotaHelper(Profile* profile);
- virtual void StartFetching(FetchResultCallback* callback) OVERRIDE;
+ virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE;
virtual void CancelNotification() OVERRIDE;
virtual void RevokeHostQuota(const std::string& host) OVERRIDE;
@@ -30,7 +29,7 @@ class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper {
private:
virtual ~MockBrowsingDataQuotaHelper();
- scoped_ptr<FetchResultCallback> callback_;
+ FetchResultCallback callback_;
std::list<QuotaInfo> response_;
Profile* profile_;
};