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 host resource call | 5 // This file provides infrastructure for dispatching host resource call |
6 // messages. Normal IPC message handlers can't take extra parameters or | 6 // messages. Normal IPC message handlers can't take extra parameters or |
7 // return values. We want to take a HostMessageContext as a parameter and | 7 // return values. We want to take a HostMessageContext as a parameter and |
8 // also return the int32_t return value to the caller. | 8 // also return the int32_t return value to the caller. |
9 | 9 |
10 #ifndef PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_ | 10 #ifndef PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d); | 54 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d); |
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 int32_t DispatchResourceCall(ObjT* obj, Method method, | 58 inline int32_t DispatchResourceCall(ObjT* obj, Method method, |
59 HostMessageContext* context, | 59 HostMessageContext* context, |
60 const Tuple5<A, B, C, D, E>& arg) { | 60 const Tuple5<A, B, C, D, E>& arg) { |
61 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d, arg.e); | 61 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d, arg.e); |
62 } | 62 } |
63 | 63 |
| 64 // Note that this only works for message with 1 or more parameters. For |
| 65 // 0-parameter messages you need to use the _0 version below (since there are |
| 66 // no Params in the message). |
64 #define PPAPI_DISPATCH_HOST_RESOURCE_CALL(msg_class, member_func) \ | 67 #define PPAPI_DISPATCH_HOST_RESOURCE_CALL(msg_class, member_func) \ |
65 case msg_class::ID: { \ | 68 case msg_class::ID: { \ |
66 TRACK_RUN_IN_IPC_HANDLER(member_func); \ | 69 TRACK_RUN_IN_IPC_HANDLER(member_func); \ |
67 msg_class::Schema::Param p; \ | 70 msg_class::Schema::Param p; \ |
68 if (msg_class::Read(&ipc_message__, &p)) { \ | 71 if (msg_class::Read(&ipc_message__, &p)) { \ |
69 return ppapi::host::DispatchResourceCall( \ | 72 return ppapi::host::DispatchResourceCall( \ |
70 this, \ | 73 this, \ |
71 &_IpcMessageHandlerClass::member_func, \ | 74 &_IpcMessageHandlerClass::member_func, \ |
72 context, p); \ | 75 context, p); \ |
73 } else { \ | 76 } \ |
74 return PP_ERROR_FAILED; \ | 77 return PP_ERROR_FAILED; \ |
75 } \ | 78 } |
76 } \ | 79 |
77 break; | 80 #define PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(msg_class, member_func) \ |
| 81 case msg_class::ID: { \ |
| 82 TRACK_RUN_IN_IPC_HANDLER(member_func); \ |
| 83 return member_func(context); \ |
| 84 } |
| 85 |
78 | 86 |
79 } // namespace host | 87 } // namespace host |
80 } // namespace ppapi | 88 } // namespace ppapi |
81 | 89 |
82 #endif // PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_ | 90 #endif // PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_ |
83 | 91 |
OLD | NEW |