gecko-dev/xpcom/threads/nsIScriptableTimer.idl

102 lines
3.7 KiB
Plaintext

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIObserver.idl"
/* -----
* NOTE:
* -----
*
* This interface is a temporary measure till nsITimer is converted
* to IDL. The hope is that nsITimer will be converted by mozilla1.0.
* See: <http://bugzilla.mozilla.org/show_bug.cgi?id=120201#c18>
*/
[scriptable,uuid(84271f22-c023-4b01-8050-d71c0c6a6235)]
interface nsIScriptableTimer : nsISupports
{
/* Timer priorities */
const short PRIORITY_HIGHEST = 10;
const short PRIORITY_HIGH = 8;
const short PRIORITY_NORMAL = 5;
const short PRIORITY_LOW = 2;
const short PRIORITY_LOWEST = 0;
/* Timer types */
const short TYPE_ONE_SHOT = 0;
const short TYPE_REPEATING_SLACK = 1;
const short TYPE_REPEATING_PRECISE = 2;
/**
* Initialize a timer that will fire after the said delay.
* A user must keep a reference to this timer till it is
* is no longer needed or has been cancelled.
*
* @param aObserver the callback object that observes the
* ``timer-callback'' topic with the subject being
* the timer itself when the timer fires:
*
* observe(nsISupports aSubject, => nsIScriptableTimer
* string aTopic, => ``timer-callback''
* wstring data => null
*
* @param aDelay delay in milliseconds for timer to fire
* @param aPriority timer priority per PRIORITY* consts defined above
* @param aType timer type per TYPE* consts defined above
*/
void init(in nsIObserver aObserver, in unsigned long aDelay,
in unsigned long aPriority, in unsigned long aType);
/**
* Cancellation of timers applies to repeating timers
* (i.e., init()ed with aType=TYPE_REPEATING*).
*/
void cancel();
};
%{C++
#ifndef NS_TIMER_CONTRACTID
#define NS_TIMER_CONTRACTID "@mozilla.org/timer;1"
#endif
#define NS_TIMER_CALLBACK_TOPIC "timer-callback"
%}