Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: ppapi/c/dev/ppb_alarms_dev.h

Issue 103993006: Add PPB_Alarms_Dev interface definition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 Thu Dec 05 16:44:32 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 * <code>period_in_minutes</code> 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
59 * <code>PP_Alarms_OnAlarm_Dev</code> event should fire.
60 */
61 struct PP_Optional_Double delay_in_minutes;
62 /**
63 * If set, the <code>PP_Alarms_OnAlarm_Dev</code> event should fire every
64 * <code>period_in_minutes</code> minutes after the initial event specified by
65 * <code>when</code> or <code>delay_in_minutes</code>. If not set, the alarm
66 * will only fire once.
67 */
68 struct PP_Optional_Double period_in_minutes;
69 };
70
71 struct PP_Alarms_Alarm_Array_Dev {
72 uint32_t size;
73 struct PP_Alarms_Alarm_Dev *elements;
74 struct PP_ArrayOutput output;
75 };
76 /**
77 * @}
78 */
79
80 /**
81 * @addtogroup Typedefs
82 * @{
83 */
84 /**
85 * Fired when an alarm has elapsed. Useful for event pages.
86 *
87 * @param[in] listener_id The listener ID.
88 * @param[inout] user_data The opaque pointer that was used when registering the
89 * listener.
90 * @param[in] alarm The alarm that has elapsed.
91 */
92 typedef void (*PP_Alarms_OnAlarm_Dev)(
93 uint32_t listener_id,
94 void* user_data,
95 const struct PP_Alarms_Alarm_Dev* alarm);
96 /**
97 * @}
98 */
99
100 /**
101 * @addtogroup Interfaces
102 * @{
103 */
104 struct PPB_Alarms_Dev_0_1 {
105 /**
106 * Creates an alarm. Near the time(s) specified by <code>alarm_info</code>,
107 * the <code>PP_Alarms_OnAlarm_Dev</code> event is fired. If there is another
108 * alarm with the same name (or no name if none is specified), it will be
109 * cancelled and replaced by this alarm.
110 *
111 * In order to reduce the load on the user's machine, Chrome limits alarms
112 * to at most once every 1 minute but may delay them an arbitrary amount more.
113 * That is, setting
114 * <code>PP_Alarms_AlarmCreateInfo_Dev.delay_in_minutes</code> or
115 * <code>PP_Alarms_AlarmCreateInfo_Dev.period_in_minutes</code> to less than
116 * <code>1</code> will not be honored and will cause a warning.
117 * <code>PP_Alarms_AlarmCreateInfo_Dev.when</code> can be set to less than 1
118 * minute after "now" without warning but won't actually cause the alarm to
119 * fire for at least 1 minute.
120 *
121 * To help you debug your app or extension, when you've loaded it unpacked,
122 * there's no limit to how often the alarm can fire.
123 *
124 * @param[in] instance A <code>PP_Instance</code>.
125 * @param[in] name A string or undefined <code>PP_Var</code>. Optional name to
126 * identify this alarm. Defaults to the empty string.
127 * @param[in] alarm_info Describes when the alarm should fire. The initial
128 * time must be specified by either <code>when</code> or
129 * <code>delay_in_minutes</code> (but not both). If
130 * <code>period_in_minutes</code> is set, the alarm will repeat every
131 * <code>period_in_minutes</code> minutes after the initial event. If neither
132 * <code>when</code> or <code>delay_in_minutes</code> is set for a repeating
133 * alarm, <code>period_in_minutes</code> is used as the default for
134 * <code>delay_in_minutes</code>.
135 */
136 void (*Create)(PP_Instance instance,
137 struct PP_Var name,
138 const struct PP_Alarms_AlarmCreateInfo_Dev* alarm_info);
139 /**
140 * Retrieves details about the specified alarm.
141 *
142 * @param[in] instance A <code>PP_Instance</code>.
143 * @param[in] name A string or undefined <code>PP_Var</code>. The name of the
144 * alarm to get. Defaults to the empty string.
145 * @param[out] alarm A <code>PP_Alarms_Alarm_Dev</code> struct to store the
146 * output result.
147 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
148 * completion.
149 *
150 * @return An error code from <code>pp_errors.h</code>
151 */
152 int32_t (*Get)(PP_Instance instance,
153 struct PP_Var name,
154 struct PP_Alarms_Alarm_Dev* alarm,
155 struct PP_CompletionCallback callback);
156 /**
157 * Gets an array of all the alarms.
158 *
159 * @param[in] instance A <code>PP_Instance</code>.
160 * @param[out] alarms A <code>PP_Alarms_Alarm_Array_Dev</code> to store the
161 * output result.
162 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
163 * completion.
164 *
165 * @return An error code from <code>pp_errors.h</code>
166 */
167 int32_t (*GetAll)(PP_Instance instance,
168 struct PP_Alarms_Alarm_Array_Dev* alarms,
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698