OLD | NEW |
| (Empty) |
1 /* Copyright (c) 2013 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 | |
6 /* From extensions/dev/ppb_ext_events_dev.idl, | |
7 * modified Mon Mar 18 17:18:20 2013. | |
8 */ | |
9 | |
10 #ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_ | |
11 #define PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_ | |
12 | |
13 #include "ppapi/c/pp_instance.h" | |
14 #include "ppapi/c/pp_macros.h" | |
15 #include "ppapi/c/pp_stdint.h" | |
16 | |
17 #define PPB_EXT_EVENTS_DEV_INTERFACE_0_1 "PPB_Ext_Events(Dev);0.1" | |
18 #define PPB_EXT_EVENTS_DEV_INTERFACE PPB_EXT_EVENTS_DEV_INTERFACE_0_1 | |
19 | |
20 /** | |
21 * @file | |
22 */ | |
23 | |
24 | |
25 /** | |
26 * @addtogroup Typedefs | |
27 * @{ | |
28 */ | |
29 /** | |
30 * Used to represent arbitrary C function pointers. Please note that usually | |
31 * the function that a <code>PP_Ext_GenericFuncType</code> pointer points to | |
32 * has a different signature than <code>void (*)()</code>. | |
33 */ | |
34 typedef void (*PP_Ext_GenericFuncType)(void); | |
35 /** | |
36 * @} | |
37 */ | |
38 | |
39 /** | |
40 * @addtogroup Structs | |
41 * @{ | |
42 */ | |
43 /** | |
44 * An event listener that can be registered with the browser and receive | |
45 * notifications via the callback function. | |
46 * | |
47 * A function is defined for each event type to return a properly-filled | |
48 * <code>PP_Ext_EventListener</code> struct, for example, | |
49 * <code>PP_Ext_Alarms_OnAlarm_Dev()</code>. | |
50 */ | |
51 struct PP_Ext_EventListener { | |
52 /** | |
53 * The name of the event to register to. | |
54 */ | |
55 const char* event_name; | |
56 /** | |
57 * A callback function whose signature is determined by | |
58 * <code>event_name</code>. All calls will happen on the same thread as the | |
59 * one on which <code>AddListener()</code> is called. | |
60 */ | |
61 PP_Ext_GenericFuncType func; | |
62 /** | |
63 * An opaque pointer that will be passed to <code>func</code>. | |
64 */ | |
65 void* user_data; | |
66 }; | |
67 /** | |
68 * @} | |
69 */ | |
70 | |
71 /** | |
72 * @addtogroup Interfaces | |
73 * @{ | |
74 */ | |
75 struct PPB_Ext_Events_Dev_0_1 { | |
76 /** | |
77 * Registers a listener to an event. | |
78 * | |
79 * @param[in] instance A <code>PP_Instance</code> identifying one instance of | |
80 * a module. | |
81 * @param[in] listener A <code>PP_Ext_EventListener</code> struct. | |
82 * | |
83 * @return An listener ID, or 0 if failed. | |
84 */ | |
85 uint32_t (*AddListener)(PP_Instance instance, | |
86 struct PP_Ext_EventListener listener); | |
87 /** | |
88 * Deregisters a listener. | |
89 * | |
90 * @param[in] instance A <code>PP_Instance</code> identifying one instance of | |
91 * a module. | |
92 * @param[in] listener_id The ID returned by <code>AddListener()</code>. | |
93 */ | |
94 void (*RemoveListener)(PP_Instance instance, uint32_t listener_id); | |
95 }; | |
96 | |
97 typedef struct PPB_Ext_Events_Dev_0_1 PPB_Ext_Events_Dev; | |
98 /** | |
99 * @} | |
100 */ | |
101 | |
102 /** | |
103 * Creates a <code>PP_Ext_EventListener</code> struct. | |
104 * | |
105 * Usually you should not call it directly. Instead you should call those | |
106 * functions that return a <code>PP_Ext_EventListener</code> struct for a | |
107 * specific event type, for example, <code>PP_Ext_Alarms_OnAlarm_Dev()</code>. | |
108 */ | |
109 PP_INLINE struct PP_Ext_EventListener PP_Ext_MakeEventListener( | |
110 const char* event_name, | |
111 PP_Ext_GenericFuncType func, | |
112 void* user_data) { | |
113 struct PP_Ext_EventListener listener; | |
114 listener.event_name = event_name; | |
115 listener.func = func; | |
116 listener.user_data = user_data; | |
117 return listener; | |
118 } | |
119 #endif /* PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_ */ | |
120 | |
OLD | NEW |