| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Use the <code>chrome.alarms</code> API to schedule code to run | 5 // Use the <code>chrome.alarms</code> API to schedule code to run |
| 6 // periodically or at a specified time in the future. | 6 // periodically or at a specified time in the future. |
| 7 namespace alarms { | 7 namespace alarms { |
| 8 dictionary Alarm { | 8 dictionary Alarm { |
| 9 // Name of this alarm. | 9 // Name of this alarm. |
| 10 DOMString name; | 10 DOMString name; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // If set, the onAlarm event should fire every <var>periodInMinutes</var> | 35 // If set, the onAlarm event should fire every <var>periodInMinutes</var> |
| 36 // minutes after the initial event specified by <var>when</var> or | 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. | 37 // <var>delayInMinutes</var>. If not set, the alarm will only fire once. |
| 38 // | 38 // |
| 39 // <!-- TODO: need minimum=0 --> | 39 // <!-- TODO: need minimum=0 --> |
| 40 double? periodInMinutes; | 40 double? periodInMinutes; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 callback AlarmCallback = void (Alarm alarm); | 43 callback AlarmCallback = void (Alarm alarm); |
| 44 callback AlarmListCallback = void (Alarm[] alarms); | 44 callback AlarmListCallback = void (Alarm[] alarms); |
| 45 callback ClearCallback = void (boolean wasCleared); |
| 45 | 46 |
| 46 interface Functions { | 47 interface Functions { |
| 47 // Creates an alarm. Near the time(s) specified by <var>alarmInfo</var>, | 48 // 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 <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 // the same name (or no name if none is specified), it will be cancelled and |
| 50 // replaced by this alarm. | 51 // replaced by this alarm. |
| 51 // | 52 // |
| 52 // In order to reduce the load on the user's machine, Chrome limits alarms | 53 // 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 // to at most once every 1 minute but may delay them an arbitrary amount |
| 54 // more. That is, setting <code>delayInMinutes</code> or | 55 // more. That is, setting <code>delayInMinutes</code> or |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 | 75 |
| 75 // Retrieves details about the specified alarm. | 76 // Retrieves details about the specified alarm. |
| 76 // |name|: The name of the alarm to get. Defaults to the empty string. | 77 // |name|: The name of the alarm to get. Defaults to the empty string. |
| 77 static void get(optional DOMString name, AlarmCallback callback); | 78 static void get(optional DOMString name, AlarmCallback callback); |
| 78 | 79 |
| 79 // Gets an array of all the alarms. | 80 // Gets an array of all the alarms. |
| 80 static void getAll(AlarmListCallback callback); | 81 static void getAll(AlarmListCallback callback); |
| 81 | 82 |
| 82 // Clears the alarm with the given name. | 83 // Clears the alarm with the given name. |
| 83 // |name|: The name of the alarm to clear. Defaults to the empty string. | 84 // |name|: The name of the alarm to clear. Defaults to the empty string. |
| 84 static void clear(optional DOMString name); | 85 static void clear(optional DOMString name, optional ClearCallback callback); |
| 85 | 86 |
| 86 // Clears all alarms. | 87 // Clears all alarms. |
| 87 static void clearAll(); | 88 static void clearAll(optional ClearCallback callback); |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 interface Events { | 91 interface Events { |
| 91 // Fired when an alarm has elapsed. Useful for event pages. | 92 // Fired when an alarm has elapsed. Useful for event pages. |
| 92 // |alarm|: The alarm that has elapsed. | 93 // |alarm|: The alarm that has elapsed. |
| 93 static void onAlarm(Alarm alarm); | 94 static void onAlarm(Alarm alarm); |
| 94 }; | 95 }; |
| 95 }; | 96 }; |
| OLD | NEW |