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

Side by Side Diff: webkit/quota/quota_types.h

Issue 10916313: Cleanup: quota::HostUsageCallback and quota::HostQuotaCallback do not need to pass host and type as… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for Kinuko Review #1 Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/quota/quota_manager_unittest.cc ('k') | webkit/quota/usage_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_QUOTA_QUOTA_TYPES_H_ 5 #ifndef WEBKIT_QUOTA_QUOTA_TYPES_H_
6 #define WEBKIT_QUOTA_QUOTA_TYPES_H_ 6 #define WEBKIT_QUOTA_QUOTA_TYPES_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 30 matching lines...) Expand all
41 41
42 // Common callback types that are used throughout in the quota module. 42 // Common callback types that are used throughout in the quota module.
43 typedef base::Callback<void(StorageType status, 43 typedef base::Callback<void(StorageType status,
44 int64 usage, 44 int64 usage,
45 int64 unlimited_usage)> GlobalUsageCallback; 45 int64 unlimited_usage)> GlobalUsageCallback;
46 typedef base::Callback<void(QuotaStatusCode status, 46 typedef base::Callback<void(QuotaStatusCode status,
47 StorageType type, 47 StorageType type,
48 int64 quota)> QuotaCallback; 48 int64 quota)> QuotaCallback;
49 // TODO(kinuko,nhiroki): HostUsageCallback could be probably replaced with 49 // TODO(kinuko,nhiroki): HostUsageCallback could be probably replaced with
50 // simple Callback<void(int64)> callback by binding host and type with Bind. 50 // simple Callback<void(int64)> callback by binding host and type with Bind.
51 typedef base::Callback<void(const std::string& host, 51 typedef base::Callback<void(int64 usage)> UsageCallback;
52 StorageType type,
53 int64 host_usage)> HostUsageCallback;
54 typedef base::Callback<void(QuotaStatusCode status, 52 typedef base::Callback<void(QuotaStatusCode status,
55 const std::string& host, 53 const std::string& host,
56 StorageType type, 54 StorageType type,
57 int64 quota)> HostQuotaCallback; 55 int64 quota)> HostQuotaCallback;
58 typedef base::Callback<void(QuotaStatusCode, int64)> AvailableSpaceCallback; 56 typedef base::Callback<void(QuotaStatusCode, int64)> AvailableSpaceCallback;
59 typedef base::Callback<void(QuotaStatusCode)> StatusCallback; 57 typedef base::Callback<void(QuotaStatusCode)> StatusCallback;
60 typedef base::Callback<void(const std::set<GURL>& origins, 58 typedef base::Callback<void(const std::set<GURL>& origins,
61 StorageType type)> GetOriginsCallback; 59 StorageType type)> GetOriginsCallback;
62 typedef base::Callback<void(const UsageInfoEntries&)> GetUsageInfoCallback; 60 typedef base::Callback<void(const UsageInfoEntries&)> GetUsageInfoCallback;
63 61
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // from the map. 194 // from the map.
197 void Run(const KEY& key, ARG1 arg1, ARG2 arg2) { 195 void Run(const KEY& key, ARG1 arg1, ARG2 arg2) {
198 if (!this->HasCallbacks(key)) 196 if (!this->HasCallbacks(key))
199 return; 197 return;
200 Queue& queue = this->callback_map_[key]; 198 Queue& queue = this->callback_map_[key];
201 queue.Run(arg1, arg2); 199 queue.Run(arg1, arg2);
202 this->callback_map_.erase(key); 200 this->callback_map_.erase(key);
203 } 201 }
204 }; 202 };
205 203
206 template <typename CallbackType3, typename KEY, 204 typedef CallbackQueueMap1<UsageCallback, std::string, int64>
207 typename ARG1, typename ARG2, typename ARG3> 205 HostUsageCallbackMap;
208 class CallbackQueueMap3
209 : public CallbackQueueMapBase<CallbackType3,
210 CallbackQueue3<CallbackType3,
211 ARG1, ARG2, ARG3>,
212 KEY> {
213 public:
214 typedef typename CallbackQueueMapBase<
215 CallbackType3,
216 CallbackQueue3<CallbackType3, ARG1, ARG2, ARG3>,
217 KEY>::iterator iterator;
218 typedef CallbackQueue3<CallbackType3, ARG1, ARG2, ARG3> Queue;
219
220 // Runs the callbacks added for the given |key| and clears the key
221 // from the map.
222 void Run(const KEY& key, ARG1 arg1, ARG2 arg2, ARG3 arg3) {
223 if (!this->HasCallbacks(key))
224 return;
225 Queue& queue = this->callback_map_[key];
226 queue.Run(arg1, arg2, arg3);
227 this->callback_map_.erase(key);
228 }
229 };
230
231 typedef CallbackQueueMap3<HostUsageCallback, std::string,
232 const std::string&,
233 StorageType, int64> HostUsageCallbackMap;
234 206
235 } // namespace quota 207 } // namespace quota
236 208
237 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_ 209 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_
OLDNEW
« no previous file with comments | « webkit/quota/quota_manager_unittest.cc ('k') | webkit/quota/usage_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698