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