Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: ppapi/host/dispatch_host_message.h

Issue 10544089: Implement the file chooser as a new resource "host" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "ipc/ipc_message_macros.h"
6
7 // This file provides infrastructure for dispatching host resource call
8 // messages. Normal IPC message handlers can't take extra parameters or
9 // return values. We want to take a HostMessageContext as a parameter and
10 // also return the int32_t return value to the caller.
11
12 #include "base/profiler/scoped_profile.h" // For TRACK_RUN_IN_IPC_HANDLER.
13 #include "ppapi/c/pp_errors.h"
14
15 namespace ppapi {
16 namespace host {
17
18 struct HostMessageContext;
19
20 template <class ObjT, class Method>
21 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
22 HostMessageContext* context,
23 const Tuple0& arg) {
24 return (obj->*method)(context);
25 }
26
27 template <class ObjT, class Method, class A>
28 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
29 HostMessageContext* context,
30 const Tuple1<A>& arg) {
31 return (obj->*method)(context, arg.a);
32 }
33
34 template<class ObjT, class Method, class A, class B>
35 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
36 HostMessageContext* context,
37 const Tuple2<A, B>& arg) {
38 return (obj->*method)(context, arg.a, arg.b);
39 }
40
41 template<class ObjT, class Method, class A, class B, class C>
42 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
43 HostMessageContext* context,
44 const Tuple3<A, B, C>& arg) {
45 return (obj->*method)(context, arg.a, arg.b, arg.c);
46 }
47
48 template<class ObjT, class Method, class A, class B, class C, class D>
49 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
50 HostMessageContext* context,
51 const Tuple4<A, B, C, D>& arg) {
52 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d);
53 }
54
55 template<class ObjT, class Method, class A, class B, class C, class D, class E>
56 inline int32_t DispatchResourceCall(ObjT* obj, Method method,
57 HostMessageContext* context,
58 const Tuple5<A, B, C, D, E>& arg) {
59 return (obj->*method)(context, arg.a, arg.b, arg.c, arg.d, arg.e);
60 }
61
62 #define PPAPI_DISPATCH_HOST_RESOURCE_CALL(msg_class, member_func) \
63 case msg_class::ID: { \
64 TRACK_RUN_IN_IPC_HANDLER(member_func); \
65 msg_class::Schema::Param p; \
66 if (msg_class::Read(&ipc_message__, &p)) { \
67 return ppapi::host::DispatchResourceCall( \
68 this, \
69 &_IpcMessageHandlerClass::member_func, \
70 context, p); \
71 } else { \
72 return PP_ERROR_FAILED; \
73 } \
74 } \
75 break;
76
77 } // namespace host
78 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698