Bumping manifests a=b2g-bump
[gecko.git] / layout / xul / nsRepeatService.h
blobc7c18c233bf459f0b97ef05512d3b8bdab81a582
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/. */
6 //
7 // nsRepeatService
8 //
9 #ifndef nsRepeatService_h__
10 #define nsRepeatService_h__
12 #include "nsCOMPtr.h"
13 #include "nsITimer.h"
15 #define INITAL_REPEAT_DELAY 250
17 #ifdef XP_MACOSX
18 #define REPEAT_DELAY 25
19 #else
20 #define REPEAT_DELAY 50
21 #endif
23 class nsITimer;
25 class nsRepeatService MOZ_FINAL : public nsITimerCallback
27 public:
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
40 // is just ignored.
41 void Stop(Callback aCallback, void* aData);
43 static nsRepeatService* GetInstance();
44 static void Shutdown();
46 NS_DECL_ISUPPORTS
48 protected:
49 nsRepeatService();
50 virtual ~nsRepeatService();
52 private:
53 Callback mCallback;
54 void* mCallbackData;
55 nsCOMPtr<nsITimer> mRepeatTimer;
56 static nsRepeatService* gInstance;
58 }; // class nsRepeatService
60 #endif