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

Side by Side Diff: ppapi/api/dev/ppb_alarms_dev.idl

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 /**
7 * This file defines the Pepper equivalent of the <code>chrome.alarms</code>
8 * extension API.
9 */
10
11 label Chrome {
12 M33 = 0.1
13 };
14
15 struct PP_Alarms_Alarm_Dev {
16 /**
17 * Name of this alarm.
18 */
19 PP_Var name;
20 /**
21 * Time at which this alarm was scheduled to fire, in milliseconds past the
22 * epoch. For performance reasons, the alarm may have been delayed an
23 * arbitrary amount beyond this.
24 */
25 double_t scheduled_time;
26 /**
27 * If set, the alarm is a repeating alarm and will fire again in
28 * <code>period_in_minutes</code> minutes.
29 */
30 PP_Optional_Double period_in_minutes;
31 };
32
33 struct PP_Alarms_AlarmCreateInfo_Dev {
34 /**
35 * Time at which the alarm should fire, in milliseconds past the epoch.
36 */
37 PP_Optional_Double when;
38 /**
39 * Length of time in minutes after which the
40 * <code>PP_Alarms_OnAlarm_Dev</code> event should fire.
41 */
42 PP_Optional_Double delay_in_minutes;
43 /**
44 * If set, the <code>PP_Alarms_OnAlarm_Dev</code> event should fire every
45 * <code>period_in_minutes</code> minutes after the initial event specified by
46 * <code>when</code> or <code>delay_in_minutes</code>. If not set, the alarm
47 * will only fire once.
48 */
49 PP_Optional_Double period_in_minutes;
dmichael (off chromium) 2013/12/06 17:44:07 Hmm, perhaps ideally |when| would be PP_Optional_T
yzshen1 2013/12/06 21:38:21 We need to do data format conversion (minute <-->
dmichael (off chromium) 2013/12/09 22:50:09 Okay, I see, I stupidly wasn't thinking about unit
50 };
51
52 struct PP_Alarms_Alarm_Array_Dev {
53 uint32_t size;
54 [size_is(count)] PP_Alarms_Alarm_Dev[] elements;
dmichael (off chromium) 2013/12/06 17:44:07 So I guess the idea is that Pepper will set |eleme
yzshen1 2013/12/06 21:38:21 Yes. That's the plan. After the browser calls PP_A
yzshen1 2013/12/09 17:56:11 Follow up: I talked with Bill and he also likes yo
dmichael (off chromium) 2013/12/09 22:50:09 I think that sounds good. We might ultimately need
yzshen1 2013/12/10 17:37:41 That sounds good. I added an work item in https://
55 PP_ArrayOutput output;
56 };
57
58 /**
59 * Fired when an alarm has elapsed. Useful for event pages.
60 *
61 * @param[in] listener_id The listener ID.
62 * @param[inout] user_data The opaque pointer that was used when registering the
63 * listener.
64 * @param[in] alarm The alarm that has elapsed.
65 */
66 typedef void PP_Alarms_OnAlarm_Dev(
67 [in] uint32_t listener_id,
68 [inout] mem_t user_data,
69 [in] PP_Alarms_Alarm_Dev alarm);
70
71 interface PPB_Alarms_Dev {
72 /**
73 * Creates an alarm. Near the time(s) specified by <code>alarm_info</code>,
74 * the <code>PP_Alarms_OnAlarm_Dev</code> event is fired. If there is another
75 * alarm with the same name (or no name if none is specified), it will be
76 * cancelled and replaced by this alarm.
77 *
78 * In order to reduce the load on the user's machine, Chrome limits alarms
79 * to at most once every 1 minute but may delay them an arbitrary amount more.
80 * That is, setting
81 * <code>PP_Alarms_AlarmCreateInfo_Dev.delay_in_minutes</code> or
82 * <code>PP_Alarms_AlarmCreateInfo_Dev.period_in_minutes</code> to less than
83 * <code>1</code> will not be honored and will cause a warning.
dmichael (off chromium) 2013/12/06 17:44:07 What kind of warning? JavaScript console? Just a l
yzshen1 2013/12/06 21:38:21 I just copied the IDL comments. I think it is a JS
84 * <code>PP_Alarms_AlarmCreateInfo_Dev.when</code> can be set to less than 1
85 * minute after "now" without warning but won't actually cause the alarm to
86 * fire for at least 1 minute.
87 *
88 * To help you debug your app or extension, when you've loaded it unpacked,
89 * there's no limit to how often the alarm can fire.
90 *
91 * @param[in] instance A <code>PP_Instance</code>.
92 * @param[in] name A string or undefined <code>PP_Var</code>. Optional name to
93 * identify this alarm. Defaults to the empty string.
94 * @param[in] alarm_info Describes when the alarm should fire. The initial
95 * time must be specified by either <code>when</code> or
96 * <code>delay_in_minutes</code> (but not both). If
97 * <code>period_in_minutes</code> is set, the alarm will repeat every
98 * <code>period_in_minutes</code> minutes after the initial event. If neither
99 * <code>when</code> or <code>delay_in_minutes</code> is set for a repeating
100 * alarm, <code>period_in_minutes</code> is used as the default for
101 * <code>delay_in_minutes</code>.
102 */
103 void Create(
104 [in] PP_Instance instance,
105 [in] PP_Var name,
106 [in] PP_Alarms_AlarmCreateInfo_Dev alarm_info);
107
108 /**
109 * Retrieves details about the specified alarm.
110 *
111 * @param[in] instance A <code>PP_Instance</code>.
112 * @param[in] name A string or undefined <code>PP_Var</code>. The name of the
113 * alarm to get. Defaults to the empty string.
114 * @param[out] alarm A <code>PP_Alarms_Alarm_Dev</code> struct to store the
115 * output result.
dmichael (off chromium) 2013/12/06 17:44:07 May be worth a note that the caller is responsible
yzshen1 2013/12/06 21:38:21 Do you think we should comment for each place? I w
116 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
117 * completion.
118 *
119 * @return An error code from <code>pp_errors.h</code>
120 */
121 int32_t Get(
122 [in] PP_Instance instance,
123 [in] PP_Var name,
124 [out] PP_Alarms_Alarm_Dev alarm,
125 [in] PP_CompletionCallback callback);
126
127 /**
128 * Gets an array of all the alarms.
129 *
130 * @param[in] instance A <code>PP_Instance</code>.
131 * @param[out] alarms A <code>PP_Alarms_Alarm_Array_Dev</code> to store the
132 * output result.
133 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
134 * completion.
135 *
136 * @return An error code from <code>pp_errors.h</code>
137 */
138 int32_t GetAll(
139 [in] PP_Instance instance,
140 [out] PP_Alarms_Alarm_Array_Dev alarms,
141 [in] PP_CompletionCallback callback);
dmichael (off chromium) 2013/12/06 17:44:07 When a 1-time Alarm has already fired, do we remov
yzshen1 2013/12/06 21:38:21 I think we should improve the Apps IDL in this cas
142
143 /**
144 * Clears the alarm with the given name.
145 *
146 * @param[in] instance A <code>PP_Instance</code>.
147 * @param[in] name A string or undefined <code>PP_Var</code>. The name of the
148 * alarm to clear. Defaults to the empty string.
dmichael (off chromium) 2013/12/06 17:44:07 What does it mean to say it defaults to the empty
yzshen1 2013/12/06 21:38:21 Copied from the Apps IDL. :/ If you think it is ne
dmichael (off chromium) 2013/12/09 22:50:09 I think this is a case where the Apps IDL comments
yzshen1 2013/12/10 17:37:41 I think the comment tried to say: if the optional
149 */
150 void Clear(
151 [in] PP_Instance instance,
152 [in] PP_Var name);
153
154 /**
155 * Clears all alarms.
156 *
157 * @param[in] instance A <code>PP_Instance</code>.
158 */
159 void ClearAll(
160 [in] PP_Instance instance);
161
162 /**
163 * Registers <code>PP_Alarms_OnAlarm_Dev</code> event.
164 *
165 * @param[in] instance A <code>PP_Instance</code>.
166 * @param[in] callback The callback to receive notifications.
167 * @param[inout] user_data An opaque pointer that will be passed to
168 * <code>callback</code>.
169 *
170 * @return A listener ID, or 0 if failed.
171 *
172 * TODO(yzshen): add a PPB_Events_Dev interface for unregistering:
173 * void UnregisterListener(PP_instance instance, uint32_t listener_id);
174 */
175 uint32_t AddOnAlarmListener(
176 [in] PP_Instance instance,
177 [in] PP_Alarms_OnAlarm_Dev callback,
178 [inout] mem_t user_data);
179 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698