| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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 // TODO(mpcomplete): We need documentation before we can release this. |
| 6 |
| 7 namespace alarms { |
| 8 dictionary Alarm { |
| 9 // Name of this alarm. |
| 10 DOMString name; |
| 11 |
| 12 // Time at which this alarm was scheduled to fire, in milliseconds past the |
| 13 // epoch (e.g. <code>Date.now() + n</code>). For performance reasons, the |
| 14 // alarm may have been delayed an arbitrary amount beyond this. |
| 15 double scheduledTime; |
| 16 |
| 17 // If not null, the alarm is a repeating alarm and will fire again in |
| 18 // <var>periodInMinutes</var> minutes. |
| 19 double? periodInMinutes; |
| 20 }; |
| 21 |
| 22 // TODO(mpcomplete): rename to CreateInfo when http://crbug.com/123073 is |
| 23 // fixed. |
| 24 dictionary AlarmCreateInfo { |
| 25 // Time at which the alarm should fire, in milliseconds past the epoch |
| 26 // (e.g. <code>Date.now() + n</code>). |
| 27 double? when; |
| 28 |
| 29 // Length of time in minutes after which the <code>onAlarm</code> event |
| 30 // should fire. |
| 31 // |
| 32 // <!-- TODO: need minimum=0 --> |
| 33 double? delayInMinutes; |
| 34 |
| 35 // If set, the onAlarm event should fire every <var>periodInMinutes</var> |
| 36 // minutes after the initial event specified by <var>when</var> or |
| 37 // <var>delayInMinutes</var>. If not set, the alarm will only fire once. |
| 38 // |
| 39 // <!-- TODO: need minimum=0 --> |
| 40 double? periodInMinutes; |
| 41 }; |
| 42 |
| 43 callback AlarmCallback = void (Alarm alarm); |
| 44 callback AlarmListCallback = void (Alarm[] alarms); |
| 45 |
| 46 interface Functions { |
| 47 // Creates an alarm. Near the time(s) specified by <var>alarmInfo</var>, |
| 48 // the <code>onAlarm</code> event is fired. If there is another alarm with |
| 49 // the same name (or no name if none is specified), it will be cancelled and |
| 50 // replaced by this alarm. |
| 51 // |
| 52 // In order to reduce the load on the user's machine, Chrome limits alarms |
| 53 // to at most once every 1 minute but may delay them an arbitrary amount |
| 54 // more. That is, setting <code>$ref:[alarms.AlarmCreateInfo.delayInMinutes |
| 55 // delayInMinutes]</code> or |
| 56 // <code>$ref:[alarms.AlarmCreateInfo.periodInMinutes |
| 57 // periodInMinutes]</code> to less than <code>1</code> will not be honored |
| 58 // and will cause a warning. <code>$ref:[alarms.AlarmCreateInfo.when |
| 59 // when]</code> can be set to less than 1 minute after "now" without |
| 60 // warning but won't actually cause the alarm to fire for at least 1 minute. |
| 61 // |
| 62 // To help you debug your app or extension, when you've loaded it unpacked, |
| 63 // there's no limit to how often the alarm can fire. |
| 64 // |
| 65 // |name|: Optional name to identify this alarm. Defaults to the empty |
| 66 // string. |
| 67 // |
| 68 // |alarmInfo|: Describes when the alarm should fire. The initial time must |
| 69 // be specified by either <var>when</var> or <var>delayInMinutes</var> (but |
| 70 // not both). If <var>periodInMinutes</var> is set, the alarm will repeat |
| 71 // every <var>periodInMinutes</var> minutes after the initial event. If |
| 72 // neither <var>when</var> or <var>delayInMinutes</var> is set for a |
| 73 // repeating alarm, <var>periodInMinutes</var> is used as the default for |
| 74 // <var>delayInMinutes</var>. |
| 75 static void create(optional DOMString name, AlarmCreateInfo alarmInfo); |
| 76 |
| 77 // Retrieves details about the specified alarm. |
| 78 // |name|: The name of the alarm to get. Defaults to the empty string. |
| 79 static void get(optional DOMString name, AlarmCallback callback); |
| 80 |
| 81 // Gets an array of all the alarms. |
| 82 static void getAll(AlarmListCallback callback); |
| 83 |
| 84 // Clears the alarm with the given name. |
| 85 // |name|: The name of the alarm to clear. Defaults to the empty string. |
| 86 static void clear(optional DOMString name); |
| 87 |
| 88 // Clears all alarms. |
| 89 static void clearAll(); |
| 90 }; |
| 91 |
| 92 interface Events { |
| 93 // Fired when an alarm has elapsed. Useful for event pages. |
| 94 // |alarm|: The alarm that has elapsed. |
| 95 static void onAlarm(Alarm alarm); |
| 96 }; |
| 97 }; |
| OLD | NEW |