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.
11 * Used to represent arbitrary C function pointers. Please note that usually
12 * the function that a <code>PP_Ext_GenericFuncType</code> pointer points to
13 * has a different signature than <code>void (*)()</code>.
15 typedef void PP_Ext_GenericFuncType
();
18 * An event listener that can be registered with the browser and receive
19 * notifications via the callback function.
21 * A function is defined for each event type to return a properly-filled
22 * <code>PP_Ext_EventListener</code> struct, for example,
23 * <code>PP_Ext_Alarms_OnAlarm_Dev()</code>.
26 struct PP_Ext_EventListener
{
28 * The name of the event to register to.
32 * A callback function whose signature is determined by
33 * <code>event_name</code>. All calls will happen on the same thread as the
34 * one on which <code>AddListener()</code> is called.
36 PP_Ext_GenericFuncType func
;
38 * An opaque pointer that will be passed to <code>func</code>.
43 interface PPB_Ext_Events_Dev
{
45 * Registers a listener to an event.
47 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
49 * @param[in] listener A <code>PP_Ext_EventListener</code> struct.
51 * @return An listener ID, or 0 if failed.
54 [in] PP_Instance instance
,
55 [in] PP_Ext_EventListener listener
);
58 * Deregisters a listener.
60 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
62 * @param[in] listener_id The ID returned by <code>AddListener()</code>.
65 [in] PP_Instance instance
,
66 [in] uint32_t listener_id
);
71 * Creates a <code>PP_Ext_EventListener</code> struct.
73 * Usually you should not call it directly. Instead you should call those
74 * functions that return a <code>PP_Ext_EventListener</code> struct for a
75 * specific event type, for example, <code>PP_Ext_Alarms_OnAlarm_Dev()</code>.
77 PP_INLINE
struct PP_Ext_EventListener PP_Ext_MakeEventListener
(
78 const char* event_name
,
79 PP_Ext_GenericFuncType func
,
81 struct PP_Ext_EventListener listener
;
82 listener.event_name
= event_name
;
84 listener.user_data
= user_data
;