OLD | NEW |
---|---|
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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <map> | 10 #include <map> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 // third_party/WebKit/Source/WebCore/dom/ExceptionCode.h. | 29 // third_party/WebKit/Source/WebCore/dom/ExceptionCode.h. |
30 enum QuotaStatusCode { | 30 enum QuotaStatusCode { |
31 kQuotaStatusOk = 0, | 31 kQuotaStatusOk = 0, |
32 kQuotaErrorNotSupported = 9, // NOT_SUPPORTED_ERR | 32 kQuotaErrorNotSupported = 9, // NOT_SUPPORTED_ERR |
33 kQuotaErrorInvalidModification = 13, // INVALID_MODIFICATION_ERR | 33 kQuotaErrorInvalidModification = 13, // INVALID_MODIFICATION_ERR |
34 kQuotaErrorInvalidAccess = 15, // INVALID_ACCESS_ERR | 34 kQuotaErrorInvalidAccess = 15, // INVALID_ACCESS_ERR |
35 kQuotaErrorAbort = 20, // ABORT_ERR | 35 kQuotaErrorAbort = 20, // ABORT_ERR |
36 kQuotaStatusUnknown = -1, | 36 kQuotaStatusUnknown = -1, |
37 }; | 37 }; |
38 | 38 |
39 struct UsageInfo; | |
40 typedef std::vector<UsageInfo> UsageInfoEntries; | |
41 | |
39 // Common callback types that are used throughout in the quota module. | 42 // Common callback types that are used throughout in the quota module. |
40 typedef Callback2<StorageType, int64>::Type UsageCallback; | 43 typedef Callback2<StorageType, int64>::Type UsageCallback; |
41 typedef Callback3<StorageType, int64, int64>::Type GlobalUsageCallback; | 44 typedef Callback3<StorageType, int64, int64>::Type GlobalUsageCallback; |
42 typedef Callback3<QuotaStatusCode, | 45 typedef Callback3<QuotaStatusCode, |
43 StorageType, | 46 StorageType, |
44 int64>::Type QuotaCallback; | 47 int64>::Type QuotaCallback; |
45 typedef Callback3<const std::string& /* host */, | 48 typedef Callback3<const std::string& /* host */, |
46 StorageType, | 49 StorageType, |
47 int64>::Type HostUsageCallback; | 50 int64>::Type HostUsageCallback; |
48 typedef Callback4<QuotaStatusCode, | 51 typedef Callback4<QuotaStatusCode, |
49 const std::string& /* host */, | 52 const std::string& /* host */, |
50 StorageType, | 53 StorageType, |
51 int64>::Type HostQuotaCallback; | 54 int64>::Type HostQuotaCallback; |
52 typedef Callback2<QuotaStatusCode, | 55 typedef Callback2<QuotaStatusCode, |
53 int64>::Type AvailableSpaceCallback; | 56 int64>::Type AvailableSpaceCallback; |
54 typedef Callback1<QuotaStatusCode>::Type StatusCallback; | 57 typedef Callback1<QuotaStatusCode>::Type StatusCallback; |
55 typedef Callback2<const std::set<GURL>&, StorageType>::Type GetOriginsCallback; | 58 typedef Callback2<const std::set<GURL>&, StorageType>::Type GetOriginsCallback; |
59 typedef Callback1<const UsageInfoEntries&>::Type GetUsageCallback; | |
kinuko
2011/10/03 07:49:20
the name GetUsageCallback is used in QuotaClients
mnaganov (inactive)
2011/10/04 03:00:40
Done.
| |
56 | 60 |
57 // Simple template wrapper for a callback queue. | 61 // Simple template wrapper for a callback queue. |
58 template <typename CallbackType> | 62 template <typename CallbackType> |
59 class CallbackQueueBase { | 63 class CallbackQueueBase { |
60 public: | 64 public: |
61 typedef typename std::deque<CallbackType> Queue; | 65 typedef typename std::deque<CallbackType> Queue; |
62 typedef typename Queue::iterator iterator; | 66 typedef typename Queue::iterator iterator; |
63 | 67 |
64 virtual ~CallbackQueueBase() { | 68 virtual ~CallbackQueueBase() { |
65 STLDeleteContainerPointers(callbacks_.begin(), callbacks_.end()); | 69 STLDeleteContainerPointers(callbacks_.begin(), callbacks_.end()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 // from the map. | 269 // from the map. |
266 void Run(const KEY& key, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) { | 270 void Run(const KEY& key, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) { |
267 if (!this->HasCallbacks(key)) | 271 if (!this->HasCallbacks(key)) |
268 return; | 272 return; |
269 Queue& queue = this->callback_map_[key]; | 273 Queue& queue = this->callback_map_[key]; |
270 queue.Run(arg1, arg2, arg3, arg4); | 274 queue.Run(arg1, arg2, arg3, arg4); |
271 this->callback_map_.erase(key); | 275 this->callback_map_.erase(key); |
272 } | 276 } |
273 }; | 277 }; |
274 | 278 |
279 typedef CallbackQueueMap1<UsageCallback*, GURL, int64> OriginUsageCallbackMap; | |
275 typedef CallbackQueueMap3<HostUsageCallback*, std::string, | 280 typedef CallbackQueueMap3<HostUsageCallback*, std::string, |
276 const std::string&, | 281 const std::string&, |
277 StorageType, int64> HostUsageCallbackMap; | 282 StorageType, int64> HostUsageCallbackMap; |
278 typedef CallbackQueueMap4<HostQuotaCallback*, std::string, | 283 typedef CallbackQueueMap4<HostQuotaCallback*, std::string, |
279 QuotaStatusCode, | 284 QuotaStatusCode, |
280 const std::string&, | 285 const std::string&, |
281 StorageType, int64> HostQuotaCallbackMap; | 286 StorageType, int64> HostQuotaCallbackMap; |
282 | 287 |
283 } // namespace quota | 288 } // namespace quota |
284 | 289 |
285 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_ | 290 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_ |
OLD | NEW |