layout/xul/nsRepeatService.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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 : public nsITimerCallback
    26 {
    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
    47   virtual ~nsRepeatService();
    49 protected:
    50   nsRepeatService();
    52 private:
    53   Callback           mCallback;
    54   void*              mCallbackData;
    55   nsCOMPtr<nsITimer> mRepeatTimer;
    56   static nsRepeatService* gInstance;
    58 }; // class nsRepeatService
    60 #endif

mercurial