Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | // |
michael@0 | 7 | // nsRepeatService |
michael@0 | 8 | // |
michael@0 | 9 | #ifndef nsRepeatService_h__ |
michael@0 | 10 | #define nsRepeatService_h__ |
michael@0 | 11 | |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsITimer.h" |
michael@0 | 14 | |
michael@0 | 15 | #define INITAL_REPEAT_DELAY 250 |
michael@0 | 16 | |
michael@0 | 17 | #ifdef XP_MACOSX |
michael@0 | 18 | #define REPEAT_DELAY 25 |
michael@0 | 19 | #else |
michael@0 | 20 | #define REPEAT_DELAY 50 |
michael@0 | 21 | #endif |
michael@0 | 22 | |
michael@0 | 23 | class nsITimer; |
michael@0 | 24 | |
michael@0 | 25 | class nsRepeatService : public nsITimerCallback |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | |
michael@0 | 29 | typedef void (* Callback)(void* aData); |
michael@0 | 30 | |
michael@0 | 31 | NS_DECL_NSITIMERCALLBACK |
michael@0 | 32 | |
michael@0 | 33 | // Start dispatching timer events to the callback. There is no memory |
michael@0 | 34 | // management of aData here; it is the caller's responsibility to call |
michael@0 | 35 | // Stop() before aData's memory is released. |
michael@0 | 36 | void Start(Callback aCallback, void* aData, |
michael@0 | 37 | uint32_t aInitialDelay = INITAL_REPEAT_DELAY); |
michael@0 | 38 | // Stop dispatching timer events to the callback. If the repeat service |
michael@0 | 39 | // is not currently configured with the given callback and data, this |
michael@0 | 40 | // is just ignored. |
michael@0 | 41 | void Stop(Callback aCallback, void* aData); |
michael@0 | 42 | |
michael@0 | 43 | static nsRepeatService* GetInstance(); |
michael@0 | 44 | static void Shutdown(); |
michael@0 | 45 | |
michael@0 | 46 | NS_DECL_ISUPPORTS |
michael@0 | 47 | virtual ~nsRepeatService(); |
michael@0 | 48 | |
michael@0 | 49 | protected: |
michael@0 | 50 | nsRepeatService(); |
michael@0 | 51 | |
michael@0 | 52 | private: |
michael@0 | 53 | Callback mCallback; |
michael@0 | 54 | void* mCallbackData; |
michael@0 | 55 | nsCOMPtr<nsITimer> mRepeatTimer; |
michael@0 | 56 | static nsRepeatService* gInstance; |
michael@0 | 57 | |
michael@0 | 58 | }; // class nsRepeatService |
michael@0 | 59 | |
michael@0 | 60 | #endif |