cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / c / extensions / dev / ppb_ext_events_dev.h
blob0c1c57ae418131d3ff9e6602784128c95aa57cf9
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 */
6 /* From extensions/dev/ppb_ext_events_dev.idl,
7 * modified Mon Mar 18 17:18:20 2013.
8 */
10 #ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_
11 #define PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_stdint.h"
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
20 /**
21 * @file
25 /**
26 * @addtogroup Typedefs
27 * @{
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>.
34 typedef void (*PP_Ext_GenericFuncType)(void);
35 /**
36 * @}
39 /**
40 * @addtogroup Structs
41 * @{
43 /**
44 * An event listener that can be registered with the browser and receive
45 * notifications via the callback function.
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>.
51 struct PP_Ext_EventListener {
52 /**
53 * The name of the event to register to.
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.
61 PP_Ext_GenericFuncType func;
62 /**
63 * An opaque pointer that will be passed to <code>func</code>.
65 void* user_data;
67 /**
68 * @}
71 /**
72 * @addtogroup Interfaces
73 * @{
75 struct PPB_Ext_Events_Dev_0_1 {
76 /**
77 * Registers a listener to an event.
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.
83 * @return An listener ID, or 0 if failed.
85 uint32_t (*AddListener)(PP_Instance instance,
86 struct PP_Ext_EventListener listener);
87 /**
88 * Deregisters a listener.
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>.
94 void (*RemoveListener)(PP_Instance instance, uint32_t listener_id);
97 typedef struct PPB_Ext_Events_Dev_0_1 PPB_Ext_Events_Dev;
98 /**
99 * @}
103 * Creates a <code>PP_Ext_EventListener</code> struct.
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>.
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;
119 #endif /* PPAPI_C_EXTENSIONS_DEV_PPB_EXT_EVENTS_DEV_H_ */