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 <tuple> |
| 14 |
13 #include "base/callback.h" | 15 #include "base/callback.h" |
14 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
15 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
16 | 18 |
17 namespace ppapi { | 19 namespace ppapi { |
18 namespace proxy { | 20 namespace proxy { |
19 | 21 |
20 class ResourceMessageReplyParams; | 22 class ResourceMessageReplyParams; |
21 | 23 |
22 template <class ObjT, class Method> | 24 template <class ObjT, class Method> |
23 inline void DispatchResourceReply(ObjT* obj, Method method, | 25 inline void DispatchResourceReply(ObjT* obj, Method method, |
24 const ResourceMessageReplyParams& params, | 26 const ResourceMessageReplyParams& params, |
25 const base::Tuple<>& arg) { | 27 const std::tuple<>& arg) { |
26 (obj->*method)(params); | 28 (obj->*method)(params); |
27 } | 29 } |
28 | 30 |
29 template <class ObjT, class Method, class A> | 31 template <class ObjT, class Method, class A> |
30 inline void DispatchResourceReply(ObjT* obj, Method method, | 32 inline void DispatchResourceReply(ObjT* obj, Method method, |
31 const ResourceMessageReplyParams& params, | 33 const ResourceMessageReplyParams& params, |
32 const base::Tuple<A>& arg) { | 34 const std::tuple<A>& arg) { |
33 (obj->*method)(params, base::get<0>(arg)); | 35 (obj->*method)(params, std::get<0>(arg)); |
34 } | 36 } |
35 | 37 |
36 template<class ObjT, class Method, class A, class B> | 38 template<class ObjT, class Method, class A, class B> |
37 inline void DispatchResourceReply(ObjT* obj, Method method, | 39 inline void DispatchResourceReply(ObjT* obj, Method method, |
38 const ResourceMessageReplyParams& params, | 40 const ResourceMessageReplyParams& params, |
39 const base::Tuple<A, B>& arg) { | 41 const std::tuple<A, B>& arg) { |
40 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg)); | 42 (obj->*method)(params, std::get<0>(arg), std::get<1>(arg)); |
41 } | 43 } |
42 | 44 |
43 template<class ObjT, class Method, class A, class B, class C> | 45 template<class ObjT, class Method, class A, class B, class C> |
44 inline void DispatchResourceReply(ObjT* obj, Method method, | 46 inline void DispatchResourceReply(ObjT* obj, Method method, |
45 const ResourceMessageReplyParams& params, | 47 const ResourceMessageReplyParams& params, |
46 const base::Tuple<A, B, C>& arg) { | 48 const std::tuple<A, B, C>& arg) { |
47 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), | 49 (obj->*method)(params, std::get<0>(arg), std::get<1>(arg), |
48 base::get<2>(arg)); | 50 std::get<2>(arg)); |
49 } | 51 } |
50 | 52 |
51 template<class ObjT, class Method, class A, class B, class C, class D> | 53 template<class ObjT, class Method, class A, class B, class C, class D> |
52 inline void DispatchResourceReply(ObjT* obj, Method method, | 54 inline void DispatchResourceReply(ObjT* obj, Method method, |
53 const ResourceMessageReplyParams& params, | 55 const ResourceMessageReplyParams& params, |
54 const base::Tuple<A, B, C, D>& arg) { | 56 const std::tuple<A, B, C, D>& arg) { |
55 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), | 57 (obj->*method)(params, std::get<0>(arg), std::get<1>(arg), |
56 base::get<2>(arg), base::get<3>(arg)); | 58 std::get<2>(arg), std::get<3>(arg)); |
57 } | 59 } |
58 | 60 |
59 template<class ObjT, class Method, class A, class B, class C, class D, class E> | 61 template<class ObjT, class Method, class A, class B, class C, class D, class E> |
60 inline void DispatchResourceReply(ObjT* obj, Method method, | 62 inline void DispatchResourceReply(ObjT* obj, Method method, |
61 const ResourceMessageReplyParams& params, | 63 const ResourceMessageReplyParams& params, |
62 const base::Tuple<A, B, C, D, E>& arg) { | 64 const std::tuple<A, B, C, D, E>& arg) { |
63 (obj->*method)(params, base::get<0>(arg), base::get<1>(arg), | 65 (obj->*method)(params, std::get<0>(arg), std::get<1>(arg), |
64 base::get<2>(arg), base::get<3>(arg), base::get<4>(arg)); | 66 std::get<2>(arg), std::get<3>(arg), std::get<4>(arg)); |
65 } | 67 } |
66 | 68 |
67 // Used to dispatch resource replies. In most cases, you should not call this | 69 // Used to dispatch resource replies. In most cases, you should not call this |
68 // function to dispatch a resource reply manually, but instead use | 70 // function to dispatch a resource reply manually, but instead use |
69 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a | 71 // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a |
70 // |base::Callback| which will be called when a reply message is received | 72 // |base::Callback| which will be called when a reply message is received |
71 // (see plugin_resource.h). | 73 // (see plugin_resource.h). |
72 // | 74 // |
73 // This function will call your callback with the nested reply message's | 75 // This function will call your callback with the nested reply message's |
74 // parameters on success. On failure, your callback will be called with each | 76 // 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... |
171 break; | 173 break; |
172 | 174 |
173 #define PPAPI_END_MESSAGE_MAP() \ | 175 #define PPAPI_END_MESSAGE_MAP() \ |
174 } \ | 176 } \ |
175 } | 177 } |
176 | 178 |
177 } // namespace proxy | 179 } // namespace proxy |
178 } // namespace ppapi | 180 } // namespace ppapi |
179 | 181 |
180 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 182 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
OLD | NEW |