/* Copyright (c) 2013 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /** * This file defines the Pepper equivalent of the chrome.alarms * extension API. */ label Chrome { M27 = 0.1 }; #inline c #include "ppapi/c/extensions/dev/ppb_ext_events_dev.h" #endinl /** * A dictionary PP_Var which contains: * - "name" : string PP_Var * Name of this alarm. * * - "scheduledTime" : double PP_Var * Time at which this alarm was scheduled to fire, in milliseconds past the * epoch (e.g. Date.now() + n). For performance reasons, the * alarm may have been delayed an arbitrary amount beyond this. * * - "periodInMinutes" : double or undefined PP_Var * If not undefined, the alarm is a repeating alarm and will fire again in * periodInMinutes minutes. */ typedef PP_Var PP_Ext_Alarms_Alarm_Dev; /** * A dictionary PP_Var which contains * - "when" : double or undefined PP_Var * Time at which the alarm should fire, in milliseconds past the epoch * (e.g. Date.now() + n). * * - "delayInMinutes" : double or undefined PP_Var * Length of time in minutes after which the * PP_Ext_Alarms_OnAlarm_Dev event should fire. * * - "periodInMinutes" : double or undefined PP_Var * If set, the PP_Ext_Alarms_OnAlarm_Dev event should fire every * periodInMinutes minutes after the initial event specified by * when or delayInMinutes. If not set, the alarm will * only fire once. */ typedef PP_Var PP_Ext_Alarms_AlarmCreateInfo_Dev; /** * An array PP_Var which contains elements of * PP_Ext_Alarms_Alarm_Dev. */ typedef PP_Var PP_Ext_Alarms_Alarm_Dev_Array; interface PPB_Ext_Alarms_Dev { /** * Creates an alarm. Near the time(s) specified by alarm_info, * the PP_Ext_Alarms_OnAlarm_Dev event is fired. If there is * another alarm with the same name (or no name if none is specified), it will * be cancelled and replaced by this alarm. * * In order to reduce the load on the user's machine, Chrome limits alarms * to at most once every 1 minute but may delay them an arbitrary amount * more. That is, setting * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.delayInMinutes * delayInMinutes] or * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.periodInMinutes * periodInMinutes] to less than 1 will not be honored * and will cause a warning. * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.when when] can be set * to less than 1 minute after "now" without warning but won't actually cause * the alarm to fire for at least 1 minute. * * To help you debug your app or extension, when you've loaded it unpacked, * there's no limit to how often the alarm can fire. * * @param[in] instance A PP_Instance. * @param[in] name A string or undefined PP_Var. Optional name to * identify this alarm. Defaults to the empty string. * @param[in] alarm_info A PP_Var whose contents conform to the * description of PP_Ext_Alarms_AlarmCreateInfo_Dev. Describes * when the alarm should fire. The initial time must be specified by either * when or delayInMinutes (but not both). If * periodInMinutes is set, the alarm will repeat every * periodInMinutes minutes after the initial event. If neither * when or delayInMinutes is set for a repeating alarm, * periodInMinutes is used as the default for * delayInMinutes. */ void Create( [in] PP_Instance instance, [in] PP_Var name, [in] PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info); /** * Retrieves details about the specified alarm. * * @param[in] instance A PP_Instance. * @param[in] name A string or undefined PP_Var. The name of the * alarm to get. Defaults to the empty string. * @param[out] alarm A PP_Var whose contents conform to the * description of PP_Ext_Alarms_Alarm_Dev. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An error code from pp_errors.h */ int32_t Get( [in] PP_Instance instance, [in] PP_Var name, [out] PP_Ext_Alarms_Alarm_Dev alarm, [in] PP_CompletionCallback callback); /** * Gets an array of all the alarms. * * @param[in] instance A PP_Instance. * @param[out] alarms A PP_Var whose contents conform to the * description of PP_Ext_Alarms_Alarm_Dev_Array. * @param[in] callback A PP_CompletionCallback to be called upon * completion. * * @return An error code from pp_errors.h */ int32_t GetAll( [in] PP_Instance instance, [out] PP_Ext_Alarms_Alarm_Dev_Array alarms, [in] PP_CompletionCallback callback); /** * Clears the alarm with the given name. * * @param[in] instance A PP_Instance. * @param[in] name A string or undefined PP_Var. The name of the * alarm to clear. Defaults to the empty string. */ void Clear( [in] PP_Instance instance, [in] PP_Var name); /** * Clears all alarms. * * @param[in] instance A PP_Instance. */ void ClearAll( [in] PP_Instance instance); }; /** * Fired when an alarm has elapsed. Useful for event pages. * * @param[in] listener_id The listener ID. * @param[inout] user_data The opaque pointer that was used when registering the * listener. * @param[in] alarm A PP_Var whose contents conform to the * description of PP_Ext_Alarms_Alarm_Dev. The alarm that has * elapsed. */ typedef void PP_Ext_Alarms_OnAlarm_Func_Dev_0_1( [in] uint32_t listener_id, [inout] mem_t user_data, [in] PP_Ext_Alarms_Alarm_Dev alarm); #inline c PP_INLINE struct PP_Ext_EventListener PP_Ext_Alarms_OnAlarm_Dev_0_1( PP_Ext_Alarms_OnAlarm_Func_Dev_0_1 func, void* user_data) { return PP_Ext_MakeEventListener("alarms.onAlarm;0.1", (PP_Ext_GenericFuncType)(func), user_data); } #define PP_Ext_Alarms_OnAlarm_Dev PP_Ext_Alarms_OnAlarm_Dev_0_1 #endinl