OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file provides infrastructure for dispatching messasges from host | 5 // This file provides infrastructure for dispatching messasges from host |
6 // resource, inlcuding reply messages or unsolicited replies. Normal IPC Reply | 6 // resource, inlcuding reply messages or unsolicited replies. Normal IPC Reply |
7 // handlers can't take extra parameters. We want to take a | 7 // handlers can't take extra parameters. We want to take a |
8 // ResourceMessageReplyParams as a parameter. | 8 // ResourceMessageReplyParams as a parameter. |
9 | 9 |
10 #ifndef PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 10 #ifndef PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
11 #define PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 11 #define PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
16 | 16 |
17 namespace ppapi { | 17 namespace ppapi { |
18 namespace proxy { | 18 namespace proxy { |
19 | 19 |
20 class ResourceMessageReplyParams; | 20 class ResourceMessageReplyParams; |
21 | 21 |
22 template <class ObjT, class Method> | 22 template <class ObjT, class Method> |
23 inline void DispatchResourceReply(ObjT* obj, Method method, | 23 inline void DispatchResourceReply(ObjT* obj, Method method, |
Nico
2014/12/22 17:03:12
can possibly be a variadic template
| |
24 const ResourceMessageReplyParams& params, | 24 const ResourceMessageReplyParams& params, |
25 const Tuple0& arg) { | 25 const Tuple<>& arg) { |
26 (obj->*method)(params); | 26 (obj->*method)(params); |
27 } | 27 } |
28 | 28 |
29 template <class ObjT, class Method, class A> | 29 template <class ObjT, class Method, class A> |
30 inline void DispatchResourceReply(ObjT* obj, Method method, | 30 inline void DispatchResourceReply(ObjT* obj, Method method, |
31 const ResourceMessageReplyParams& params, | 31 const ResourceMessageReplyParams& params, |
32 const Tuple1<A>& arg) { | 32 const Tuple<A>& arg) { |
33 (obj->*method)(params, arg.a); | 33 (obj->*method)(params, get<0>(arg)); |
34 } | 34 } |
35 | 35 |
36 template<class ObjT, class Method, class A, class B> | 36 template<class ObjT, class Method, class A, class B> |
37 inline void DispatchResourceReply(ObjT* obj, Method method, | 37 inline void DispatchResourceReply(ObjT* obj, Method method, |
38 const ResourceMessageReplyParams& params, | 38 const ResourceMessageReplyParams& params, |
39 const Tuple2<A, B>& arg) { | 39 const Tuple<A, B>& arg) { |
40 (obj->*method)(params, arg.a, arg.b); | 40 (obj->*method)(params, get<0>(arg), get<1>(arg)); |
41 } | 41 } |
42 | 42 |
43 template<class ObjT, class Method, class A, class B, class C> | 43 template<class ObjT, class Method, class A, class B, class C> |
44 inline void DispatchResourceReply(ObjT* obj, Method method, | 44 inline void DispatchResourceReply(ObjT* obj, Method method, |
45 const ResourceMessageReplyParams& params, | 45 const ResourceMessageReplyParams& params, |
46 const Tuple3<A, B, C>& arg) { | 46 const Tuple<A, B, C>& arg) { |
47 (obj->*method)(params, arg.a, arg.b, arg.c); | 47 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg)); |
48 } | 48 } |
49 | 49 |
50 template<class ObjT, class Method, class A, class B, class C, class D> | 50 template<class ObjT, class Method, class A, class B, class C, class D> |
51 inline void DispatchResourceReply(ObjT* obj, Method method, | 51 inline void DispatchResourceReply(ObjT* obj, Method method, |
52 const ResourceMessageReplyParams& params, | 52 const ResourceMessageReplyParams& params, |
53 const Tuple4<A, B, C, D>& arg) { | 53 const Tuple<A, B, C, D>& arg) { |
54 (obj->*method)(params, arg.a, arg.b, arg.c, arg.d); | 54 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg)); |
55 } | 55 } |
56 | 56 |
57 template<class ObjT, class Method, class A, class B, class C, class D, class E> | 57 template<class ObjT, class Method, class A, class B, class C, class D, class E> |
58 inline void DispatchResourceReply(ObjT* obj, Method method, | 58 inline void DispatchResourceReply(ObjT* obj, Method method, |
59 const ResourceMessageReplyParams& params, | 59 const ResourceMessageReplyParams& params, |
60 const Tuple5<A, B, C, D, E>& arg) { | 60 const Tuple<A, B, C, D, E>& arg) { |
61 (obj->*method)(params, arg.a, arg.b, arg.c, arg.d, arg.e); | 61 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg), |
62 get<4>(arg)); | |
62 } | 63 } |
63 | 64 |
64 // Used to dispatch resource replies. In most cases, you should not call this | 65 // Used to dispatch resource replies. In most cases, you should not call this |
65 // function to dispatch a resource reply manually, but instead use | 66 // function to dispatch a resource reply manually, but instead use |
66 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a | 67 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a |
67 // |base::Callback| which will be called when a reply message is received | 68 // |base::Callback| which will be called when a reply message is received |
68 // (see plugin_resource.h). | 69 // (see plugin_resource.h). |
69 // | 70 // |
70 // This function will call your callback with the nested reply message's | 71 // This function will call your callback with the nested reply message's |
71 // parameters on success. On failure, your callback will be called with each | 72 // parameters on success. On failure, your callback will be called with each |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 break; | 169 break; |
169 | 170 |
170 #define PPAPI_END_MESSAGE_MAP() \ | 171 #define PPAPI_END_MESSAGE_MAP() \ |
171 } \ | 172 } \ |
172 } | 173 } |
173 | 174 |
174 } // namespace proxy | 175 } // namespace proxy |
175 } // namespace ppapi | 176 } // namespace ppapi |
176 | 177 |
177 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 178 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
OLD | NEW |