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

Side by Side Diff: media/base/bind_to_loop.h

Issue 10855188: media::BindToLoop() is born, with example uses to slim down WebMediaPlayerProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with macro Created 8 years, 4 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 | « no previous file | media/base/bind_to_loop.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
(Empty)
1 // This file was GENERATED by command:
2 // pump.py bind_to_loop.h.pump
3 // DO NOT EDIT BY HAND!!!
4
5
6 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 Now with tests!
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file.
9
10 #ifndef MEDIA_BASE_BIND_TO_LOOP_H_
11 #define MEDIA_BASE_BIND_TO_LOOP_H_
12
13 #include "base/bind.h"
14 #include "base/message_loop_proxy.h"
15
16 // This is a helper utility for base::Bind()ing callbacks on to particular
17 // MessageLoops. A typical use is when |a| (of class |A|) wants to hand a
18 // callback such as base::Bind(&A::AMethod, a) to |b|, but needs to ensure that
19 // when |b| executes the callback, it does so on a particular MessageLoop.
20 //
21 // Typical usage: request to be called back on the current thread:
22 // other->StartAsyncProcessAndCallMeBack(
23 // media::BindToLoop(MessageLoopProxy::current(),
24 // base::Bind(&MyClass::MyMethod, this)));
25
26 namespace media {
27
28 static void TrampolineRun(
awong 2012/08/16 17:19:21 Should these be in an internal namespace? Also, s
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 The "static"s are leftover from prototyping. Gone
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 You mean put TrampolineRun in media::internal but
29 scoped_refptr<base::MessageLoopProxy> loop, const base::Closure& cb) {
awong 2012/08/16 17:19:21 Can |loop| be a const ref?
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 Done.
30 loop->PostTask(FROM_HERE, base::Bind(cb));
31 }
32
33 static base::Closure BindToLoop(
34 scoped_refptr<base::MessageLoopProxy> loop, const base::Closure& cb) {
35 return base::Bind(&TrampolineRun, loop, cb);
36 }
37
38 template<typename A1>
39 static void TrampolineRun(
40 scoped_refptr<base::MessageLoopProxy> loop,
41 const base::Callback<void(A1)>& cb,
42 A1 a1) {
awong 2012/08/16 17:19:21 We're not unwrapping A1 into a ForwardType like Ca
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 I'd rather things worked across the board, and I w
43 loop->PostTask(FROM_HERE, base::Bind(cb, a1));
44 }
45
46 template<typename A1>
47 static base::Callback<void(A1)> BindToLoop(
48 scoped_refptr<base::MessageLoopProxy> loop,
49 const base::Callback<void(A1)>& cb) {
50 return base::Bind(&TrampolineRun<A1>, loop, cb);
51 }
52
53 template<typename A1, typename A2>
54 static void TrampolineRun(
55 scoped_refptr<base::MessageLoopProxy> loop,
56 const base::Callback<void(A1, A2)>& cb,
57 A1 a1, A2 a2) {
58 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2));
59 }
60
61 template<typename A1, typename A2>
62 static base::Callback<void(A1, A2)> BindToLoop(
63 scoped_refptr<base::MessageLoopProxy> loop,
64 const base::Callback<void(A1, A2)>& cb) {
65 return base::Bind(&TrampolineRun<A1, A2>, loop, cb);
66 }
67
68 template<typename A1, typename A2, typename A3>
69 static void TrampolineRun(
awong 2012/08/16 17:19:21 If you use the funciton-signature trick to make Tr
Ami GONE FROM CHROMIUM 2012/08/16 20:25:53 Nice, done.
70 scoped_refptr<base::MessageLoopProxy> loop,
71 const base::Callback<void(A1, A2, A3)>& cb,
72 A1 a1, A2 a2, A3 a3) {
73 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2, a3));
74 }
75
76 template<typename A1, typename A2, typename A3>
77 static base::Callback<void(A1, A2, A3)> BindToLoop(
78 scoped_refptr<base::MessageLoopProxy> loop,
79 const base::Callback<void(A1, A2, A3)>& cb) {
80 return base::Bind(&TrampolineRun<A1, A2, A3>, loop, cb);
81 }
82
83 template<typename A1, typename A2, typename A3, typename A4>
84 static void TrampolineRun(
85 scoped_refptr<base::MessageLoopProxy> loop,
86 const base::Callback<void(A1, A2, A3, A4)>& cb,
87 A1 a1, A2 a2, A3 a3, A4 a4) {
88 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2, a3, a4));
89 }
90
91 template<typename A1, typename A2, typename A3, typename A4>
92 static base::Callback<void(A1, A2, A3, A4)> BindToLoop(
93 scoped_refptr<base::MessageLoopProxy> loop,
94 const base::Callback<void(A1, A2, A3, A4)>& cb) {
95 return base::Bind(&TrampolineRun<A1, A2, A3, A4>, loop, cb);
96 }
97
98 template<typename A1, typename A2, typename A3, typename A4, typename A5>
99 static void TrampolineRun(
100 scoped_refptr<base::MessageLoopProxy> loop,
101 const base::Callback<void(A1, A2, A3, A4, A5)>& cb,
102 A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
103 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2, a3, a4, a5));
104 }
105
106 template<typename A1, typename A2, typename A3, typename A4, typename A5>
107 static base::Callback<void(A1, A2, A3, A4, A5)> BindToLoop(
108 scoped_refptr<base::MessageLoopProxy> loop,
109 const base::Callback<void(A1, A2, A3, A4, A5)>& cb) {
110 return base::Bind(&TrampolineRun<A1, A2, A3, A4, A5>, loop, cb);
111 }
112
113 template<typename A1, typename A2, typename A3, typename A4, typename A5,
114 typename A6>
115 static void TrampolineRun(
116 scoped_refptr<base::MessageLoopProxy> loop,
117 const base::Callback<void(A1, A2, A3, A4, A5, A6)>& cb,
118 A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
119 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2, a3, a4, a5, a6));
120 }
121
122 template<typename A1, typename A2, typename A3, typename A4, typename A5,
123 typename A6>
124 static base::Callback<void(A1, A2, A3, A4, A5, A6)> BindToLoop(
125 scoped_refptr<base::MessageLoopProxy> loop,
126 const base::Callback<void(A1, A2, A3, A4, A5, A6)>& cb) {
127 return base::Bind(&TrampolineRun<A1, A2, A3, A4, A5, A6>, loop, cb);
128 }
129
130 template<typename A1, typename A2, typename A3, typename A4, typename A5,
131 typename A6, typename A7>
132 static void TrampolineRun(
133 scoped_refptr<base::MessageLoopProxy> loop,
134 const base::Callback<void(A1, A2, A3, A4, A5, A6, A7)>& cb,
135 A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
136 loop->PostTask(FROM_HERE, base::Bind(cb, a1, a2, a3, a4, a5, a6, a7));
137 }
138
139 template<typename A1, typename A2, typename A3, typename A4, typename A5,
140 typename A6, typename A7>
141 static base::Callback<void(A1, A2, A3, A4, A5, A6, A7)> BindToLoop(
142 scoped_refptr<base::MessageLoopProxy> loop,
143 const base::Callback<void(A1, A2, A3, A4, A5, A6, A7)>& cb) {
144 return base::Bind(&TrampolineRun<A1, A2, A3, A4, A5, A6, A7>, loop, cb);
145 }
146
147 } // namespace media
148
149 #endif // MEDIA_BASE_BIND_TO_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/bind_to_loop.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698