OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file provides infrastructure for dispatching host resource reply |
| 6 // messages. Normal IPC Reply handlers can't take extra parameters. |
| 7 // We want to take a ResourceMessageReplyParams as a parameter. |
| 8 |
| 9 #ifndef PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
| 10 #define PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
| 11 |
| 12 #include "base/profiler/scoped_profile.h" // For TRACK_RUN_IN_IPC_HANDLER. |
| 13 #include "ipc/ipc_message_macros.h" |
| 14 #include "ppapi/c/pp_errors.h" |
| 15 |
| 16 namespace ppapi { |
| 17 namespace proxy { |
| 18 |
| 19 struct Context; |
| 20 class ResourceMessageReplyParams; |
| 21 |
| 22 template <class ObjT, class Method> |
| 23 inline void DispatchResourceReply(ObjT* obj, Method method, |
| 24 const ResourceMessageReplyParams& params, |
| 25 const Tuple0& arg) { |
| 26 (obj->*method)(params); |
| 27 } |
| 28 |
| 29 template <class ObjT, class Method, class A> |
| 30 inline void DispatchResourceReply(ObjT* obj, Method method, |
| 31 const ResourceMessageReplyParams& params, |
| 32 const Tuple1<A>& arg) { |
| 33 return (obj->*method)(params, arg.a); |
| 34 } |
| 35 |
| 36 template<class ObjT, class Method, class A, class B> |
| 37 inline int32_t DispatchResourceReply(ObjT* obj, Method method, |
| 38 const ResourceMessageReplyParams& params, |
| 39 const Tuple2<A, B>& arg) { |
| 40 return (obj->*method)(params, arg.a, arg.b); |
| 41 } |
| 42 |
| 43 template<class ObjT, class Method, class A, class B, class C> |
| 44 inline void DispatchResourceReply(ObjT* obj, Method method, |
| 45 const ResourceMessageReplyParams& params, |
| 46 const Tuple3<A, B, C>& arg) { |
| 47 return (obj->*method)(params, arg.a, arg.b, arg.c); |
| 48 } |
| 49 |
| 50 template<class ObjT, class Method, class A, class B, class C, class D> |
| 51 inline void DispatchResourceReply(ObjT* obj, Method method, |
| 52 const ResourceMessageReplyParams& params, |
| 53 const Tuple4<A, B, C, D>& arg) { |
| 54 return (obj->*method)(params, arg.a, arg.b, arg.c, arg.d); |
| 55 } |
| 56 |
| 57 template<class ObjT, class Method, class A, class B, class C, class D, class E> |
| 58 inline void DispatchResourceReply(ObjT* obj, Method method, |
| 59 const ResourceMessageReplyParams& params, |
| 60 const Tuple5<A, B, C, D, E>& arg) { |
| 61 return (obj->*method)(params, arg.a, arg.b, arg.c, arg.d, arg.e); |
| 62 } |
| 63 |
| 64 #define PPAPI_DISPATCH_RESOURCE_REPLY(msg_class, member_func) \ |
| 65 case msg_class::ID: { \ |
| 66 TRACK_RUN_IN_IPC_HANDLER(member_func); \ |
| 67 msg_class::Schema::Param p; \ |
| 68 if (msg_class::Read(&ipc_message__, &p)) { \ |
| 69 ppapi::proxy::DispatchResourceReply( \ |
| 70 this, \ |
| 71 &_IpcMessageHandlerClass::member_func, \ |
| 72 params, p); \ |
| 73 } \ |
| 74 } \ |
| 75 break; |
| 76 |
| 77 } // namespace proxy |
| 78 } // namespace ppapi |
| 79 |
| 80 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
OLD | NEW |