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

Side by Side Diff: mojo/public/bindings/callback.h

Issue 218613010: Mojo: Move mojo/public/bindings/*.h to mojo/public/cpp/bindings/*.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « mojo/public/bindings/buffer.h ('k') | mojo/public/bindings/callback.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 callback.h.pump
3 // DO NOT EDIT BY HAND!!!
4
5
6
7 // Copyright 2014 The Chromium Authors. All rights reserved.
8 // Use of this source code is governed by a BSD-style license that can be
9 // found in the LICENSE file.
10
11 #ifndef MOJO_PUBLIC_BINDINGS_CALLBACK_H_
12 #define MOJO_PUBLIC_BINDINGS_CALLBACK_H_
13
14 #include "mojo/public/bindings/lib/callback_internal.h"
15 #include "mojo/public/bindings/lib/shared_ptr.h"
16
17 namespace mojo {
18
19 template <typename Sig>
20 class Callback;
21
22 template <>
23 class Callback<void()> {
24 public:
25 struct Runnable {
26 virtual ~Runnable() {}
27 virtual void Run() const = 0;
28 };
29
30 Callback() {}
31
32 // The Callback assumes ownership of |runnable|.
33 explicit Callback(Runnable* runnable) : sink_(runnable) {}
34
35 // Any class that is copy-constructable and has a compatible Run method may
36 // be adapted to a Callback using this constructor.
37 template <typename Sink>
38 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
39
40 void Run() const {
41 if (sink_.get())
42 sink_->Run();
43 }
44
45 private:
46 template <typename Sink>
47 struct Adapter : public Runnable {
48 explicit Adapter(const Sink& sink) : sink(sink) {}
49 virtual void Run() const MOJO_OVERRIDE {
50 sink.Run();
51 }
52 Sink sink;
53 };
54
55 internal::SharedPtr<Runnable> sink_;
56 };
57
58 template <typename A1>
59 class Callback<void(A1)> {
60 public:
61 struct Runnable {
62 virtual ~Runnable() {}
63 virtual void Run(
64 typename internal::Callback_ParamTraits<A1>::ForwardType a1) const = 0;
65 };
66
67 Callback() {}
68
69 // The Callback assumes ownership of |runnable|.
70 explicit Callback(Runnable* runnable) : sink_(runnable) {}
71
72 // Any class that is copy-constructable and has a compatible Run method may
73 // be adapted to a Callback using this constructor.
74 template <typename Sink>
75 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
76
77 void Run(
78 typename internal::Callback_ParamTraits<A1>::ForwardType a1) const {
79 if (sink_.get())
80 sink_->Run(
81 internal::Callback_Forward(a1));
82 }
83
84 private:
85 template <typename Sink>
86 struct Adapter : public Runnable {
87 explicit Adapter(const Sink& sink) : sink(sink) {}
88 virtual void Run(
89 typename internal::Callback_ParamTraits<A1>::ForwardType a1) const
90 MOJO_OVERRIDE {
91 sink.Run(
92 internal::Callback_Forward(a1));
93 }
94 Sink sink;
95 };
96
97 internal::SharedPtr<Runnable> sink_;
98 };
99
100 template <typename A1, typename A2>
101 class Callback<void(A1, A2)> {
102 public:
103 struct Runnable {
104 virtual ~Runnable() {}
105 virtual void Run(
106 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
107 typename internal::Callback_ParamTraits<A2>::ForwardType a2) const = 0;
108 };
109
110 Callback() {}
111
112 // The Callback assumes ownership of |runnable|.
113 explicit Callback(Runnable* runnable) : sink_(runnable) {}
114
115 // Any class that is copy-constructable and has a compatible Run method may
116 // be adapted to a Callback using this constructor.
117 template <typename Sink>
118 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
119
120 void Run(
121 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
122 typename internal::Callback_ParamTraits<A2>::ForwardType a2) const {
123 if (sink_.get())
124 sink_->Run(
125 internal::Callback_Forward(a1),
126 internal::Callback_Forward(a2));
127 }
128
129 private:
130 template <typename Sink>
131 struct Adapter : public Runnable {
132 explicit Adapter(const Sink& sink) : sink(sink) {}
133 virtual void Run(
134 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
135 typename internal::Callback_ParamTraits<A2>::ForwardType a2) const
136 MOJO_OVERRIDE {
137 sink.Run(
138 internal::Callback_Forward(a1),
139 internal::Callback_Forward(a2));
140 }
141 Sink sink;
142 };
143
144 internal::SharedPtr<Runnable> sink_;
145 };
146
147 template <typename A1, typename A2, typename A3>
148 class Callback<void(A1, A2, A3)> {
149 public:
150 struct Runnable {
151 virtual ~Runnable() {}
152 virtual void Run(
153 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
154 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
155 typename internal::Callback_ParamTraits<A3>::ForwardType a3) const = 0;
156 };
157
158 Callback() {}
159
160 // The Callback assumes ownership of |runnable|.
161 explicit Callback(Runnable* runnable) : sink_(runnable) {}
162
163 // Any class that is copy-constructable and has a compatible Run method may
164 // be adapted to a Callback using this constructor.
165 template <typename Sink>
166 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
167
168 void Run(
169 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
170 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
171 typename internal::Callback_ParamTraits<A3>::ForwardType a3) const {
172 if (sink_.get())
173 sink_->Run(
174 internal::Callback_Forward(a1),
175 internal::Callback_Forward(a2),
176 internal::Callback_Forward(a3));
177 }
178
179 private:
180 template <typename Sink>
181 struct Adapter : public Runnable {
182 explicit Adapter(const Sink& sink) : sink(sink) {}
183 virtual void Run(
184 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
185 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
186 typename internal::Callback_ParamTraits<A3>::ForwardType a3) const
187 MOJO_OVERRIDE {
188 sink.Run(
189 internal::Callback_Forward(a1),
190 internal::Callback_Forward(a2),
191 internal::Callback_Forward(a3));
192 }
193 Sink sink;
194 };
195
196 internal::SharedPtr<Runnable> sink_;
197 };
198
199 template <typename A1, typename A2, typename A3, typename A4>
200 class Callback<void(A1, A2, A3, A4)> {
201 public:
202 struct Runnable {
203 virtual ~Runnable() {}
204 virtual void Run(
205 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
206 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
207 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
208 typename internal::Callback_ParamTraits<A4>::ForwardType a4) const = 0;
209 };
210
211 Callback() {}
212
213 // The Callback assumes ownership of |runnable|.
214 explicit Callback(Runnable* runnable) : sink_(runnable) {}
215
216 // Any class that is copy-constructable and has a compatible Run method may
217 // be adapted to a Callback using this constructor.
218 template <typename Sink>
219 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
220
221 void Run(
222 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
223 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
224 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
225 typename internal::Callback_ParamTraits<A4>::ForwardType a4) const {
226 if (sink_.get())
227 sink_->Run(
228 internal::Callback_Forward(a1),
229 internal::Callback_Forward(a2),
230 internal::Callback_Forward(a3),
231 internal::Callback_Forward(a4));
232 }
233
234 private:
235 template <typename Sink>
236 struct Adapter : public Runnable {
237 explicit Adapter(const Sink& sink) : sink(sink) {}
238 virtual void Run(
239 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
240 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
241 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
242 typename internal::Callback_ParamTraits<A4>::ForwardType a4) const
243 MOJO_OVERRIDE {
244 sink.Run(
245 internal::Callback_Forward(a1),
246 internal::Callback_Forward(a2),
247 internal::Callback_Forward(a3),
248 internal::Callback_Forward(a4));
249 }
250 Sink sink;
251 };
252
253 internal::SharedPtr<Runnable> sink_;
254 };
255
256 template <typename A1, typename A2, typename A3, typename A4, typename A5>
257 class Callback<void(A1, A2, A3, A4, A5)> {
258 public:
259 struct Runnable {
260 virtual ~Runnable() {}
261 virtual void Run(
262 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
263 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
264 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
265 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
266 typename internal::Callback_ParamTraits<A5>::ForwardType a5) const = 0;
267 };
268
269 Callback() {}
270
271 // The Callback assumes ownership of |runnable|.
272 explicit Callback(Runnable* runnable) : sink_(runnable) {}
273
274 // Any class that is copy-constructable and has a compatible Run method may
275 // be adapted to a Callback using this constructor.
276 template <typename Sink>
277 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
278
279 void Run(
280 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
281 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
282 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
283 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
284 typename internal::Callback_ParamTraits<A5>::ForwardType a5) const {
285 if (sink_.get())
286 sink_->Run(
287 internal::Callback_Forward(a1),
288 internal::Callback_Forward(a2),
289 internal::Callback_Forward(a3),
290 internal::Callback_Forward(a4),
291 internal::Callback_Forward(a5));
292 }
293
294 private:
295 template <typename Sink>
296 struct Adapter : public Runnable {
297 explicit Adapter(const Sink& sink) : sink(sink) {}
298 virtual void Run(
299 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
300 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
301 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
302 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
303 typename internal::Callback_ParamTraits<A5>::ForwardType a5) const
304 MOJO_OVERRIDE {
305 sink.Run(
306 internal::Callback_Forward(a1),
307 internal::Callback_Forward(a2),
308 internal::Callback_Forward(a3),
309 internal::Callback_Forward(a4),
310 internal::Callback_Forward(a5));
311 }
312 Sink sink;
313 };
314
315 internal::SharedPtr<Runnable> sink_;
316 };
317
318 template <typename A1, typename A2, typename A3, typename A4, typename A5,
319 typename A6>
320 class Callback<void(A1, A2, A3, A4, A5, A6)> {
321 public:
322 struct Runnable {
323 virtual ~Runnable() {}
324 virtual void Run(
325 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
326 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
327 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
328 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
329 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
330 typename internal::Callback_ParamTraits<A6>::ForwardType a6) const = 0;
331 };
332
333 Callback() {}
334
335 // The Callback assumes ownership of |runnable|.
336 explicit Callback(Runnable* runnable) : sink_(runnable) {}
337
338 // Any class that is copy-constructable and has a compatible Run method may
339 // be adapted to a Callback using this constructor.
340 template <typename Sink>
341 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
342
343 void Run(
344 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
345 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
346 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
347 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
348 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
349 typename internal::Callback_ParamTraits<A6>::ForwardType a6) const {
350 if (sink_.get())
351 sink_->Run(
352 internal::Callback_Forward(a1),
353 internal::Callback_Forward(a2),
354 internal::Callback_Forward(a3),
355 internal::Callback_Forward(a4),
356 internal::Callback_Forward(a5),
357 internal::Callback_Forward(a6));
358 }
359
360 private:
361 template <typename Sink>
362 struct Adapter : public Runnable {
363 explicit Adapter(const Sink& sink) : sink(sink) {}
364 virtual void Run(
365 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
366 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
367 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
368 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
369 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
370 typename internal::Callback_ParamTraits<A6>::ForwardType a6) const
371 MOJO_OVERRIDE {
372 sink.Run(
373 internal::Callback_Forward(a1),
374 internal::Callback_Forward(a2),
375 internal::Callback_Forward(a3),
376 internal::Callback_Forward(a4),
377 internal::Callback_Forward(a5),
378 internal::Callback_Forward(a6));
379 }
380 Sink sink;
381 };
382
383 internal::SharedPtr<Runnable> sink_;
384 };
385
386 template <typename A1, typename A2, typename A3, typename A4, typename A5,
387 typename A6, typename A7>
388 class Callback<void(A1, A2, A3, A4, A5, A6, A7)> {
389 public:
390 struct Runnable {
391 virtual ~Runnable() {}
392 virtual void Run(
393 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
394 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
395 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
396 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
397 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
398 typename internal::Callback_ParamTraits<A6>::ForwardType a6,
399 typename internal::Callback_ParamTraits<A7>::ForwardType a7) const = 0;
400 };
401
402 Callback() {}
403
404 // The Callback assumes ownership of |runnable|.
405 explicit Callback(Runnable* runnable) : sink_(runnable) {}
406
407 // Any class that is copy-constructable and has a compatible Run method may
408 // be adapted to a Callback using this constructor.
409 template <typename Sink>
410 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {}
411
412 void Run(
413 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
414 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
415 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
416 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
417 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
418 typename internal::Callback_ParamTraits<A6>::ForwardType a6,
419 typename internal::Callback_ParamTraits<A7>::ForwardType a7) const {
420 if (sink_.get())
421 sink_->Run(
422 internal::Callback_Forward(a1),
423 internal::Callback_Forward(a2),
424 internal::Callback_Forward(a3),
425 internal::Callback_Forward(a4),
426 internal::Callback_Forward(a5),
427 internal::Callback_Forward(a6),
428 internal::Callback_Forward(a7));
429 }
430
431 private:
432 template <typename Sink>
433 struct Adapter : public Runnable {
434 explicit Adapter(const Sink& sink) : sink(sink) {}
435 virtual void Run(
436 typename internal::Callback_ParamTraits<A1>::ForwardType a1,
437 typename internal::Callback_ParamTraits<A2>::ForwardType a2,
438 typename internal::Callback_ParamTraits<A3>::ForwardType a3,
439 typename internal::Callback_ParamTraits<A4>::ForwardType a4,
440 typename internal::Callback_ParamTraits<A5>::ForwardType a5,
441 typename internal::Callback_ParamTraits<A6>::ForwardType a6,
442 typename internal::Callback_ParamTraits<A7>::ForwardType a7) const
443 MOJO_OVERRIDE {
444 sink.Run(
445 internal::Callback_Forward(a1),
446 internal::Callback_Forward(a2),
447 internal::Callback_Forward(a3),
448 internal::Callback_Forward(a4),
449 internal::Callback_Forward(a5),
450 internal::Callback_Forward(a6),
451 internal::Callback_Forward(a7));
452 }
453 Sink sink;
454 };
455
456 internal::SharedPtr<Runnable> sink_;
457 };
458
459 } // namespace mojo
460
461 #endif // MOJO_PUBLIC_BINDINGS_CALLBACK_H_
OLDNEW
« no previous file with comments | « mojo/public/bindings/buffer.h ('k') | mojo/public/bindings/callback.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698