dom/plugins/ipc/ChildTimer.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=8 et :
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef mozilla_plugins_ChildTimer_h
     9 #define mozilla_plugins_ChildTimer_h
    11 #include "PluginMessageUtils.h"
    12 #include "npapi.h"
    13 #include "base/timer.h"
    15 namespace mozilla {
    16 namespace plugins {
    18 class PluginInstanceChild;
    19 typedef void (*TimerFunc)(NPP npp, uint32_t timerID);
    21 class ChildTimer
    22 {
    23 public:
    24   /**
    25    * If initialization failed, ID() will return 0.
    26    */
    27   ChildTimer(PluginInstanceChild* instance,
    28              uint32_t interval,
    29              bool repeat,
    30              TimerFunc func);
    31   ~ChildTimer() { }
    33   uint32_t ID() const { return mID; }
    35   class IDComparator
    36   {
    37   public:
    38     bool Equals(ChildTimer* t, uint32_t id) const {
    39       return t->ID() == id;
    40     }
    41   };
    43 private:
    44   PluginInstanceChild* mInstance;
    45   TimerFunc mFunc;
    46   bool mRepeating;
    47   uint32_t mID;
    48   base::RepeatingTimer<ChildTimer> mTimer;
    50   void Run();
    52   static uint32_t gNextTimerID;
    53 };
    55 } // namespace plugins
    56 } // namespace mozilla
    58 #endif // mozilla_plugins_ChildTimer_h

mercurial