| 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_alarms_dev.idl modified Tue Mar 05 14:02:41 2013. */ | |
| 7 | |
| 8 #ifndef PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ | |
| 9 #define PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ | |
| 10 | |
| 11 #include "ppapi/c/pp_bool.h" | |
| 12 #include "ppapi/c/pp_completion_callback.h" | |
| 13 #include "ppapi/c/pp_instance.h" | |
| 14 #include "ppapi/c/pp_macros.h" | |
| 15 #include "ppapi/c/pp_stdint.h" | |
| 16 #include "ppapi/c/pp_var.h" | |
| 17 | |
| 18 #define PPB_EXT_ALARMS_DEV_INTERFACE_0_1 "PPB_Ext_Alarms(Dev);0.1" | |
| 19 #define PPB_EXT_ALARMS_DEV_INTERFACE PPB_EXT_ALARMS_DEV_INTERFACE_0_1 | |
| 20 | |
| 21 /** | |
| 22 * @file | |
| 23 * This file defines the Pepper equivalent of the <code>chrome.alarms</code> | |
| 24 * extension API. | |
| 25 */ | |
| 26 | |
| 27 | |
| 28 #include "ppapi/c/extensions/dev/ppb_events_dev.h" | |
| 29 | |
| 30 /** | |
| 31 * @addtogroup Typedefs | |
| 32 * @{ | |
| 33 */ | |
| 34 /** | |
| 35 * A dictionary <code>PP_Var</code> which contains: | |
| 36 * - "name" : string <code>PP_Var</code> | |
| 37 * Name of this alarm. | |
| 38 * | |
| 39 * - "scheduledTime" : double <code>PP_Var</code> | |
| 40 * Time at which this alarm was scheduled to fire, in milliseconds past the | |
| 41 * epoch (e.g. <code>Date.now() + n</code>). For performance reasons, the | |
| 42 * alarm may have been delayed an arbitrary amount beyond this. | |
| 43 * | |
| 44 * - "periodInMinutes" : double or undefined <code>PP_Var</code> | |
| 45 * If not undefined, the alarm is a repeating alarm and will fire again in | |
| 46 * <var>periodInMinutes</var> minutes. | |
| 47 */ | |
| 48 typedef struct PP_Var PP_Ext_Alarms_Alarm_Dev; | |
| 49 | |
| 50 /** | |
| 51 * A dictionary <code>PP_Var</code> which contains | |
| 52 * - "when" : double or undefined <code>PP_Var</code> | |
| 53 * Time at which the alarm should fire, in milliseconds past the epoch | |
| 54 * (e.g. <code>Date.now() + n</code>). | |
| 55 * | |
| 56 * - "delayInMinutes" : double or undefined <code>PP_Var</code> | |
| 57 * Length of time in minutes after which the | |
| 58 * <code>PP_Ext_Alarms_OnAlarm_Dev</code> event should fire. | |
| 59 * | |
| 60 * - "periodInMinutes" : double or undefined <code>PP_Var</code> | |
| 61 * If set, the <code>PP_Ext_Alarms_OnAlarm_Dev</code> event should fire every | |
| 62 * <var>periodInMinutes</var> minutes after the initial event specified by | |
| 63 * <var>when</var> or <var>delayInMinutes</var>. If not set, the alarm will | |
| 64 * only fire once. | |
| 65 */ | |
| 66 typedef struct PP_Var PP_Ext_Alarms_AlarmCreateInfo_Dev; | |
| 67 | |
| 68 /** | |
| 69 * An array <code>PP_Var</code> which contains elements of | |
| 70 * <code>PP_Ext_Alarms_Alarm_Dev</code>. | |
| 71 */ | |
| 72 typedef struct PP_Var PP_Ext_Alarms_Alarm_Dev_Array; | |
| 73 /** | |
| 74 * @} | |
| 75 */ | |
| 76 | |
| 77 /** | |
| 78 * @addtogroup Interfaces | |
| 79 * @{ | |
| 80 */ | |
| 81 struct PPB_Ext_Alarms_Dev_0_1 { | |
| 82 /** | |
| 83 * Creates an alarm. Near the time(s) specified by <var>alarm_info</var>, | |
| 84 * the <code>PP_Ext_Alarms_OnAlarm_Dev</code> event is fired. If there is | |
| 85 * another alarm with the same name (or no name if none is specified), it will | |
| 86 * be cancelled and replaced by this alarm. | |
| 87 * | |
| 88 * In order to reduce the load on the user's machine, Chrome limits alarms | |
| 89 * to at most once every 1 minute but may delay them an arbitrary amount | |
| 90 * more. That is, setting | |
| 91 * <code>$ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.delayInMinutes | |
| 92 * delayInMinutes]</code> or | |
| 93 * <code>$ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.periodInMinutes | |
| 94 * periodInMinutes]</code> to less than <code>1</code> will not be honored | |
| 95 * and will cause a warning. | |
| 96 * <code>$ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.when when]</code> can be set | |
| 97 * to less than 1 minute after "now" without warning but won't actually cause | |
| 98 * the alarm to fire for at least 1 minute. | |
| 99 * | |
| 100 * To help you debug your app or extension, when you've loaded it unpacked, | |
| 101 * there's no limit to how often the alarm can fire. | |
| 102 * | |
| 103 * @param[in] instance A <code>PP_Instance</code>. | |
| 104 * @param[in] name A string or undefined <code>PP_Var</code>. Optional name to | |
| 105 * identify this alarm. Defaults to the empty string. | |
| 106 * @param[in] alarm_info A <code>PP_Var</code> whose contents conform to the | |
| 107 * description of <code>PP_Ext_Alarms_AlarmCreateInfo_Dev</code>. Describes | |
| 108 * when the alarm should fire. The initial time must be specified by either | |
| 109 * <var>when</var> or <var>delayInMinutes</var> (but not both). If | |
| 110 * <var>periodInMinutes</var> is set, the alarm will repeat every | |
| 111 * <var>periodInMinutes</var> minutes after the initial event. If neither | |
| 112 * <var>when</var> or <var>delayInMinutes</var> is set for a repeating alarm, | |
| 113 * <var>periodInMinutes</var> is used as the default for | |
| 114 * <var>delayInMinutes</var>. | |
| 115 */ | |
| 116 void (*Create)(PP_Instance instance, | |
| 117 struct PP_Var name, | |
| 118 PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info); | |
| 119 /** | |
| 120 * Retrieves details about the specified alarm. | |
| 121 * | |
| 122 * @param[in] instance A <code>PP_Instance</code>. | |
| 123 * @param[in] name A string or undefined <code>PP_Var</code>. The name of the | |
| 124 * alarm to get. Defaults to the empty string. | |
| 125 * @param[out] alarm A <code>PP_Var</code> whose contents conform to the | |
| 126 * description of <code>PP_Ext_Alarms_Alarm_Dev</code>. | |
| 127 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | |
| 128 * completion. | |
| 129 * | |
| 130 * @return An error code from <code>pp_errors.h</code> | |
| 131 */ | |
| 132 int32_t (*Get)(PP_Instance instance, | |
| 133 struct PP_Var name, | |
| 134 PP_Ext_Alarms_Alarm_Dev* alarm, | |
| 135 struct PP_CompletionCallback callback); | |
| 136 /** | |
| 137 * Gets an array of all the alarms. | |
| 138 * | |
| 139 * @param[in] instance A <code>PP_Instance</code>. | |
| 140 * @param[out] alarms A <code>PP_Var</code> whose contents conform to the | |
| 141 * description of <code>PP_Ext_Alarms_Alarm_Dev_Array</code>. | |
| 142 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | |
| 143 * completion. | |
| 144 * | |
| 145 * @return An error code from <code>pp_errors.h</code> | |
| 146 */ | |
| 147 int32_t (*GetAll)(PP_Instance instance, | |
| 148 PP_Ext_Alarms_Alarm_Dev_Array* alarms, | |
| 149 struct PP_CompletionCallback callback); | |
| 150 /** | |
| 151 * Clears the alarm with the given name. | |
| 152 * | |
| 153 * @param[in] instance A <code>PP_Instance</code>. | |
| 154 * @param[in] name A string or undefined <code>PP_Var</code>. The name of the | |
| 155 * alarm to clear. Defaults to the empty string. | |
| 156 */ | |
| 157 void (*Clear)(PP_Instance instance, struct PP_Var name); | |
| 158 /** | |
| 159 * Clears all alarms. | |
| 160 * | |
| 161 * @param[in] instance A <code>PP_Instance</code>. | |
| 162 */ | |
| 163 void (*ClearAll)(PP_Instance instance); | |
| 164 }; | |
| 165 | |
| 166 typedef struct PPB_Ext_Alarms_Dev_0_1 PPB_Ext_Alarms_Dev; | |
| 167 /** | |
| 168 * @} | |
| 169 */ | |
| 170 | |
| 171 /** | |
| 172 * @addtogroup Typedefs | |
| 173 * @{ | |
| 174 */ | |
| 175 /** | |
| 176 * Fired when an alarm has elapsed. Useful for event pages. | |
| 177 * | |
| 178 * @param[in] listener_id The listener ID. | |
| 179 * @param[inout] user_data The opaque pointer that was used when registering the | |
| 180 * listener. | |
| 181 * @param[in] alarm A <code>PP_Var</code> whose contents conform to the | |
| 182 * description of <code>PP_Ext_Alarms_Alarm_Dev</code>. The alarm that has | |
| 183 * elapsed. | |
| 184 */ | |
| 185 typedef void (*PP_Ext_Alarms_OnAlarm_Func_Dev_0_1)( | |
| 186 uint32_t listener_id, | |
| 187 void* user_data, | |
| 188 PP_Ext_Alarms_Alarm_Dev alarm); | |
| 189 /** | |
| 190 * @} | |
| 191 */ | |
| 192 | |
| 193 PP_INLINE struct PP_Ext_EventListener PP_Ext_Alarms_OnAlarm_Dev_0_1( | |
| 194 PP_Ext_Alarms_OnAlarm_Func_Dev_0_1 func, | |
| 195 void* user_data) { | |
| 196 return PP_Ext_MakeEventListener("alarms.onAlarm;0.1", | |
| 197 (PP_Ext_GenericFuncType)(func), user_data); | |
| 198 } | |
| 199 | |
| 200 #define PP_Ext_Alarms_OnAlarm_Dev PP_Ext_Alarms_OnAlarm_Dev_0_1 | |
| 201 #endif /* PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ */ | |
| 202 | |
| OLD | NEW |