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

Side by Side Diff: base/callback_list.h

Issue 618573002: [Base] Use variadic template in callback_list.h (wave 1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/callback_list.h.pump » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This file was GENERATED by command:
2 // pump.py callback_list.h.pump
3 // DO NOT EDIT BY HAND!!!
4
5
6 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
7 // 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
8 // found in the LICENSE file. 3 // found in the LICENSE file.
9 4
10 #ifndef BASE_CALLBACK_LIST_H_ 5 #ifndef BASE_CALLBACK_LIST_H_
11 #define BASE_CALLBACK_LIST_H_ 6 #define BASE_CALLBACK_LIST_H_
12 7
13 #include <list> 8 #include <list>
14 9
15 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 int active_iterator_count_; 196 int active_iterator_count_;
202 Closure removal_callback_; 197 Closure removal_callback_;
203 198
204 DISALLOW_COPY_AND_ASSIGN(CallbackListBase); 199 DISALLOW_COPY_AND_ASSIGN(CallbackListBase);
205 }; 200 };
206 201
207 } // namespace internal 202 } // namespace internal
208 203
209 template <typename Sig> class CallbackList; 204 template <typename Sig> class CallbackList;
210 205
211 template <> 206 template <typename... Args>
212 class CallbackList<void(void)> 207 class CallbackList<void(Args...)>
213 : public internal::CallbackListBase<Callback<void(void)> > { 208 : public internal::CallbackListBase<Callback<void(Args...)> > {
214 public: 209 public:
215 typedef Callback<void(void)> CallbackType; 210 typedef Callback<void(Args...)> CallbackType;
216 211
217 CallbackList() {} 212 CallbackList() {}
218 213
219 void Notify() { 214 void Notify(
220 internal::CallbackListBase<CallbackType>::Iterator it = 215 typename internal::CallbackParamTraits<Args>::ForwardType... args) {
221 this->GetIterator();
222 CallbackType* cb;
223 while ((cb = it.GetNext()) != NULL) {
224 cb->Run();
225 }
226 }
227
228 private:
229 DISALLOW_COPY_AND_ASSIGN(CallbackList);
230 };
231
232 template <typename A1>
233 class CallbackList<void(A1)>
234 : public internal::CallbackListBase<Callback<void(A1)> > {
235 public:
236 typedef Callback<void(A1)> CallbackType;
237
238 CallbackList() {}
239
240 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1) {
241 typename internal::CallbackListBase<CallbackType>::Iterator it = 216 typename internal::CallbackListBase<CallbackType>::Iterator it =
242 this->GetIterator(); 217 this->GetIterator();
243 CallbackType* cb; 218 CallbackType* cb;
244 while ((cb = it.GetNext()) != NULL) { 219 while ((cb = it.GetNext()) != NULL) {
245 cb->Run(a1); 220 cb->Run(args...);
246 } 221 }
247 } 222 }
248 223
249 private:
250 DISALLOW_COPY_AND_ASSIGN(CallbackList);
251 };
252
253 template <typename A1, typename A2>
254 class CallbackList<void(A1, A2)>
255 : public internal::CallbackListBase<Callback<void(A1, A2)> > {
256 public:
257 typedef Callback<void(A1, A2)> CallbackType;
258
259 CallbackList() {}
260
261 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
262 typename internal::CallbackParamTraits<A2>::ForwardType a2) {
263 typename internal::CallbackListBase<CallbackType>::Iterator it =
264 this->GetIterator();
265 CallbackType* cb;
266 while ((cb = it.GetNext()) != NULL) {
267 cb->Run(a1, a2);
268 }
269 }
270
271 private:
272 DISALLOW_COPY_AND_ASSIGN(CallbackList);
273 };
274
275 template <typename A1, typename A2, typename A3>
276 class CallbackList<void(A1, A2, A3)>
277 : public internal::CallbackListBase<Callback<void(A1, A2, A3)> > {
278 public:
279 typedef Callback<void(A1, A2, A3)> CallbackType;
280
281 CallbackList() {}
282
283 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
284 typename internal::CallbackParamTraits<A2>::ForwardType a2,
285 typename internal::CallbackParamTraits<A3>::ForwardType a3) {
286 typename internal::CallbackListBase<CallbackType>::Iterator it =
287 this->GetIterator();
288 CallbackType* cb;
289 while ((cb = it.GetNext()) != NULL) {
290 cb->Run(a1, a2, a3);
291 }
292 }
293
294 private:
295 DISALLOW_COPY_AND_ASSIGN(CallbackList);
296 };
297
298 template <typename A1, typename A2, typename A3, typename A4>
299 class CallbackList<void(A1, A2, A3, A4)>
300 : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4)> > {
301 public:
302 typedef Callback<void(A1, A2, A3, A4)> CallbackType;
303
304 CallbackList() {}
305
306 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
307 typename internal::CallbackParamTraits<A2>::ForwardType a2,
308 typename internal::CallbackParamTraits<A3>::ForwardType a3,
309 typename internal::CallbackParamTraits<A4>::ForwardType a4) {
310 typename internal::CallbackListBase<CallbackType>::Iterator it =
311 this->GetIterator();
312 CallbackType* cb;
313 while ((cb = it.GetNext()) != NULL) {
314 cb->Run(a1, a2, a3, a4);
315 }
316 }
317
318 private:
319 DISALLOW_COPY_AND_ASSIGN(CallbackList);
320 };
321
322 template <typename A1, typename A2, typename A3, typename A4, typename A5>
323 class CallbackList<void(A1, A2, A3, A4, A5)>
324 : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5)> > {
325 public:
326 typedef Callback<void(A1, A2, A3, A4, A5)> CallbackType;
327
328 CallbackList() {}
329
330 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
331 typename internal::CallbackParamTraits<A2>::ForwardType a2,
332 typename internal::CallbackParamTraits<A3>::ForwardType a3,
333 typename internal::CallbackParamTraits<A4>::ForwardType a4,
334 typename internal::CallbackParamTraits<A5>::ForwardType a5) {
335 typename internal::CallbackListBase<CallbackType>::Iterator it =
336 this->GetIterator();
337 CallbackType* cb;
338 while ((cb = it.GetNext()) != NULL) {
339 cb->Run(a1, a2, a3, a4, a5);
340 }
341 }
342
343 private:
344 DISALLOW_COPY_AND_ASSIGN(CallbackList);
345 };
346
347 template <typename A1, typename A2, typename A3, typename A4, typename A5,
348 typename A6>
349 class CallbackList<void(A1, A2, A3, A4, A5, A6)>
350 : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5,
351 A6)> > {
352 public:
353 typedef Callback<void(A1, A2, A3, A4, A5, A6)> CallbackType;
354
355 CallbackList() {}
356
357 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
358 typename internal::CallbackParamTraits<A2>::ForwardType a2,
359 typename internal::CallbackParamTraits<A3>::ForwardType a3,
360 typename internal::CallbackParamTraits<A4>::ForwardType a4,
361 typename internal::CallbackParamTraits<A5>::ForwardType a5,
362 typename internal::CallbackParamTraits<A6>::ForwardType a6) {
363 typename internal::CallbackListBase<CallbackType>::Iterator it =
364 this->GetIterator();
365 CallbackType* cb;
366 while ((cb = it.GetNext()) != NULL) {
367 cb->Run(a1, a2, a3, a4, a5, a6);
368 }
369 }
370
371 private:
372 DISALLOW_COPY_AND_ASSIGN(CallbackList);
373 };
374
375 template <typename A1, typename A2, typename A3, typename A4, typename A5,
376 typename A6, typename A7>
377 class CallbackList<void(A1, A2, A3, A4, A5, A6, A7)>
378 : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5, A6,
379 A7)> > {
380 public:
381 typedef Callback<void(A1, A2, A3, A4, A5, A6, A7)> CallbackType;
382
383 CallbackList() {}
384
385 void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
386 typename internal::CallbackParamTraits<A2>::ForwardType a2,
387 typename internal::CallbackParamTraits<A3>::ForwardType a3,
388 typename internal::CallbackParamTraits<A4>::ForwardType a4,
389 typename internal::CallbackParamTraits<A5>::ForwardType a5,
390 typename internal::CallbackParamTraits<A6>::ForwardType a6,
391 typename internal::CallbackParamTraits<A7>::ForwardType a7) {
392 typename internal::CallbackListBase<CallbackType>::Iterator it =
393 this->GetIterator();
394 CallbackType* cb;
395 while ((cb = it.GetNext()) != NULL) {
396 cb->Run(a1, a2, a3, a4, a5, a6, a7);
397 }
398 }
399
400 private: 224 private:
401 DISALLOW_COPY_AND_ASSIGN(CallbackList); 225 DISALLOW_COPY_AND_ASSIGN(CallbackList);
402 }; 226 };
403 227
404 } // namespace base 228 } // namespace base
405 229
406 #endif // BASE_CALLBACK_LIST_H_ 230 #endif // BASE_CALLBACK_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | base/callback_list.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698