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

Unified Diff: webkit/quota/quota_types.h

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 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 | « webkit/quota/quota_temporary_storage_evictor_unittest.cc ('k') | webkit/quota/usage_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/quota/quota_types.h
diff --git a/webkit/quota/quota_types.h b/webkit/quota/quota_types.h
index a07c14cf86f377189c9f0299313f36a88eecdf05..b14be0c2d0da64ba2736eca43f067dacb555e2cf 100644
--- a/webkit/quota/quota_types.h
+++ b/webkit/quota/quota_types.h
@@ -10,10 +10,10 @@
#include <map>
#include <set>
#include <string>
+#include <vector>
#include "base/basictypes.h"
-#include "base/callback_old.h"
-#include "base/stl_util.h"
+#include "base/callback.h"
class GURL;
@@ -40,23 +40,21 @@ struct UsageInfo;
typedef std::vector<UsageInfo> UsageInfoEntries;
// Common callback types that are used throughout in the quota module.
-typedef Callback2<StorageType, int64>::Type UsageCallback;
-typedef Callback3<StorageType, int64, int64>::Type GlobalUsageCallback;
-typedef Callback3<QuotaStatusCode,
- StorageType,
- int64>::Type QuotaCallback;
-typedef Callback3<const std::string& /* host */,
- StorageType,
- int64>::Type HostUsageCallback;
-typedef Callback4<QuotaStatusCode,
- const std::string& /* host */,
- StorageType,
- int64>::Type HostQuotaCallback;
-typedef Callback2<QuotaStatusCode,
- int64>::Type AvailableSpaceCallback;
-typedef Callback1<QuotaStatusCode>::Type StatusCallback;
-typedef Callback2<const std::set<GURL>&, StorageType>::Type GetOriginsCallback;
-typedef Callback1<const UsageInfoEntries&>::Type GetUsageInfoCallback;
+typedef base::Callback<void(StorageType, int64)> UsageCallback;
+typedef base::Callback<void(StorageType, int64, int64)> GlobalUsageCallback;
+typedef base::Callback<void(QuotaStatusCode, StorageType, int64)>
+ QuotaCallback;
+typedef base::Callback<void(const std::string&, StorageType, int64)>
+ HostUsageCallback;
+typedef base::Callback<void(QuotaStatusCode,
+ const std::string&,
+ StorageType,
+ int64)> HostQuotaCallback;
+typedef base::Callback<void(QuotaStatusCode, int64)> AvailableSpaceCallback;
+typedef base::Callback<void(QuotaStatusCode)> StatusCallback;
+typedef base::Callback<void(const std::set<GURL>&, StorageType)>
+ GetOriginsCallback;
+typedef base::Callback<void(const UsageInfoEntries&)> GetUsageInfoCallback;
// Simple template wrapper for a callback queue.
template <typename CallbackType>
@@ -65,12 +63,10 @@ class CallbackQueueBase {
typedef typename std::deque<CallbackType> Queue;
typedef typename Queue::iterator iterator;
- virtual ~CallbackQueueBase() {
- STLDeleteContainerPointers(callbacks_.begin(), callbacks_.end());
- }
+ virtual ~CallbackQueueBase() {}
// Returns true if the given |callback| is the first one added to the queue.
- bool Add(CallbackType callback) {
+ bool Add(const CallbackType& callback) {
callbacks_.push_back(callback);
return (callbacks_.size() == 1);
}
@@ -92,8 +88,7 @@ class CallbackQueue1 : public CallbackQueueBase<CallbackType1> {
// Note: template-derived class needs 'this->' to access its base class.
for (typename Queue::iterator iter = this->callbacks_.begin();
iter != this->callbacks_.end(); ++iter) {
- (*iter)->Run(arg);
- delete *iter;
+ iter->Run(arg);
}
this->callbacks_.clear();
}
@@ -107,8 +102,7 @@ class CallbackQueue2 : public CallbackQueueBase<CallbackType2> {
void Run(A1 arg1, A2 arg2) {
for (typename Queue::iterator iter = this->callbacks_.begin();
iter != this->callbacks_.end(); ++iter) {
- (*iter)->Run(arg1, arg2);
- delete *iter;
+ iter->Run(arg1, arg2);
}
this->callbacks_.clear();
}
@@ -122,8 +116,7 @@ class CallbackQueue3 : public CallbackQueueBase<CallbackType3> {
void Run(A1 arg1, A2 arg2, A3 arg3) {
for (typename Queue::iterator iter = this->callbacks_.begin();
iter != this->callbacks_.end(); ++iter) {
- (*iter)->Run(arg1, arg2, arg3);
- delete *iter;
+ iter->Run(arg1, arg2, arg3);
}
this->callbacks_.clear();
}
@@ -138,18 +131,17 @@ class CallbackQueue4 : public CallbackQueueBase<CallbackType4> {
void Run(A1 arg1, A2 arg2, A3 arg3, A4 arg4) {
for (typename Queue::iterator iter = this->callbacks_.begin();
iter != this->callbacks_.end(); ++iter) {
- (*iter)->Run(arg1, arg2, arg3, arg4);
- delete *iter;
+ iter->Run(arg1, arg2, arg3, arg4);
}
this->callbacks_.clear();
}
};
-typedef CallbackQueue2<UsageCallback*,
+typedef CallbackQueue2<UsageCallback,
StorageType, int64> UsageCallbackQueue;
-typedef CallbackQueue3<GlobalUsageCallback*,
+typedef CallbackQueue3<GlobalUsageCallback,
StorageType, int64, int64> GlobalUsageCallbackQueue;
-typedef CallbackQueue3<QuotaCallback*,
+typedef CallbackQueue3<QuotaCallback,
QuotaStatusCode,
StorageType, int64> QuotaCallbackQueue;
@@ -159,7 +151,7 @@ class CallbackQueueMapBase {
typedef std::map<KEY, CallbackQueueType> CallbackMap;
typedef typename CallbackMap::iterator iterator;
- bool Add(const KEY& key, CallbackType callback) {
+ bool Add(const KEY& key, const CallbackType& callback) {
return callback_map_[key].Add(callback);
}
@@ -276,11 +268,11 @@ class CallbackQueueMap4
}
};
-typedef CallbackQueueMap1<UsageCallback*, GURL, int64> OriginUsageCallbackMap;
-typedef CallbackQueueMap3<HostUsageCallback*, std::string,
+typedef CallbackQueueMap1<UsageCallback, GURL, int64> OriginUsageCallbackMap;
+typedef CallbackQueueMap3<HostUsageCallback, std::string,
const std::string&,
StorageType, int64> HostUsageCallbackMap;
-typedef CallbackQueueMap4<HostQuotaCallback*, std::string,
+typedef CallbackQueueMap4<HostQuotaCallback, std::string,
QuotaStatusCode,
const std::string&,
StorageType, int64> HostQuotaCallbackMap;
« no previous file with comments | « webkit/quota/quota_temporary_storage_evictor_unittest.cc ('k') | webkit/quota/usage_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698