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, |
24 const ResourceMessageReplyParams& params, | 24 const ResourceMessageReplyParams& params, |
25 const Tuple<>& arg) { | 25 const base::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 Tuple<A>& arg) { | 32 const base::Tuple<A>& arg) { |
33 (obj->*method)(params, get<0>(arg)); | 33 (obj->*method)(params, base::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 Tuple<A, B>& arg) { | 39 const base::Tuple<A, B>& arg) { |
40 (obj->*method)(params, get<0>(arg), get<1>(arg)); | 40 (obj->*method)(params, base::get<0>(arg), base::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 Tuple<A, B, C>& arg) { | 46 const base::Tuple<A, B, C>& arg) { |
47 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg)); | 47 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), |
| 48 base::get<2>(arg)); |
48 } | 49 } |
49 | 50 |
50 template<class ObjT, class Method, class A, class B, class C, class D> | 51 template<class ObjT, class Method, class A, class B, class C, class D> |
51 inline void DispatchResourceReply(ObjT* obj, Method method, | 52 inline void DispatchResourceReply(ObjT* obj, Method method, |
52 const ResourceMessageReplyParams& params, | 53 const ResourceMessageReplyParams& params, |
53 const Tuple<A, B, C, D>& arg) { | 54 const base::Tuple<A, B, C, D>& arg) { |
54 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg)); | 55 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), |
| 56 base::get<2>(arg), base::get<3>(arg)); |
55 } | 57 } |
56 | 58 |
57 template<class ObjT, class Method, class A, class B, class C, class D, class E> | 59 template<class ObjT, class Method, class A, class B, class C, class D, class E> |
58 inline void DispatchResourceReply(ObjT* obj, Method method, | 60 inline void DispatchResourceReply(ObjT* obj, Method method, |
59 const ResourceMessageReplyParams& params, | 61 const ResourceMessageReplyParams& params, |
60 const Tuple<A, B, C, D, E>& arg) { | 62 const base::Tuple<A, B, C, D, E>& arg) { |
61 (obj->*method)(params, get<0>(arg), get<1>(arg), get<2>(arg), get<3>(arg), | 63 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), |
62 get<4>(arg)); | 64 base::get<2>(arg), base::get<3>(arg), base::get<4>(arg)); |
63 } | 65 } |
64 | 66 |
65 // Used to dispatch resource replies. In most cases, you should not call this | 67 // Used to dispatch resource replies. In most cases, you should not call this |
66 // function to dispatch a resource reply manually, but instead use | 68 // function to dispatch a resource reply manually, but instead use |
67 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a | 69 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a |
68 // |base::Callback| which will be called when a reply message is received | 70 // |base::Callback| which will be called when a reply message is received |
69 // (see plugin_resource.h). | 71 // (see plugin_resource.h). |
70 // | 72 // |
71 // This function will call your callback with the nested reply message's | 73 // This function will call your callback with the nested reply message's |
72 // parameters on success. On failure, your callback will be called with each | 74 // 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... |
169 break; | 171 break; |
170 | 172 |
171 #define PPAPI_END_MESSAGE_MAP() \ | 173 #define PPAPI_END_MESSAGE_MAP() \ |
172 } \ | 174 } \ |
173 } | 175 } |
174 | 176 |
175 } // namespace proxy | 177 } // namespace proxy |
176 } // namespace ppapi | 178 } // namespace ppapi |
177 | 179 |
178 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 180 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
OLD | NEW |