1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef nsRepeatService_h__
10 #define nsRepeatService_h__
15 #define INITAL_REPEAT_DELAY 250
18 #define REPEAT_DELAY 25
20 #define REPEAT_DELAY 50
25 class nsRepeatService MOZ_FINAL
: public nsITimerCallback
29 typedef void (* Callback
)(void* aData
);
31 NS_DECL_NSITIMERCALLBACK
33 // Start dispatching timer events to the callback. There is no memory
34 // management of aData here; it is the caller's responsibility to call
35 // Stop() before aData's memory is released.
36 void Start(Callback aCallback
, void* aData
,
37 uint32_t aInitialDelay
= INITAL_REPEAT_DELAY
);
38 // Stop dispatching timer events to the callback. If the repeat service
39 // is not currently configured with the given callback and data, this
41 void Stop(Callback aCallback
, void* aData
);
43 static nsRepeatService
* GetInstance();
44 static void Shutdown();
50 virtual ~nsRepeatService();
55 nsCOMPtr
<nsITimer
> mRepeatTimer
;
56 static nsRepeatService
* gInstance
;
58 }; // class nsRepeatService