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 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // from the map. | 163 // from the map. |
164 void Run(const KEY& key, ARG arg) { | 164 void Run(const KEY& key, ARG arg) { |
165 if (!this->HasCallbacks(key)) | 165 if (!this->HasCallbacks(key)) |
166 return; | 166 return; |
167 Queue& queue = this->callback_map_[key]; | 167 Queue& queue = this->callback_map_[key]; |
168 queue.Run(arg); | 168 queue.Run(arg); |
169 this->callback_map_.erase(key); | 169 this->callback_map_.erase(key); |
170 } | 170 } |
171 }; | 171 }; |
172 | 172 |
173 template <typename CallbackType2, typename KEY, typename ARG1, typename ARG2> | |
174 class CallbackQueueMap2 | |
175 : public CallbackQueueMapBase<CallbackType2, | |
176 CallbackQueue2<CallbackType2, ARG1, ARG2>, | |
177 KEY> { | |
178 public: | |
179 typedef typename CallbackQueueMapBase< | |
180 CallbackType2, | |
181 CallbackQueue2<CallbackType2, ARG1, ARG2>, | |
182 KEY>::iterator iterator; | |
183 typedef CallbackQueue2<CallbackType2, ARG1, ARG2> Queue; | |
184 | |
185 // Runs the callbacks added for the given |key| and clears the key | |
186 // from the map. | |
187 void Run(const KEY& key, ARG1 arg1, ARG2 arg2) { | |
188 if (!this->HasCallbacks(key)) | |
189 return; | |
190 Queue& queue = this->callback_map_[key]; | |
191 queue.Run(arg1, arg2); | |
192 this->callback_map_.erase(key); | |
193 } | |
194 }; | |
195 | |
196 typedef CallbackQueueMap1<UsageCallback, std::string, int64> | 173 typedef CallbackQueueMap1<UsageCallback, std::string, int64> |
197 HostUsageCallbackMap; | 174 HostUsageCallbackMap; |
198 | 175 |
199 } // namespace quota | 176 } // namespace quota |
200 | 177 |
201 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_ | 178 #endif // WEBKIT_QUOTA_QUOTA_TYPES_H_ |
OLD | NEW |