dom/plugins/ipc/ChildTimer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/ipc/ChildTimer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * vim: sw=2 ts=8 et :
     1.6 + */
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef mozilla_plugins_ChildTimer_h
    1.12 +#define mozilla_plugins_ChildTimer_h
    1.13 +
    1.14 +#include "PluginMessageUtils.h"
    1.15 +#include "npapi.h"
    1.16 +#include "base/timer.h"
    1.17 +
    1.18 +namespace mozilla {
    1.19 +namespace plugins {
    1.20 +
    1.21 +class PluginInstanceChild;
    1.22 +typedef void (*TimerFunc)(NPP npp, uint32_t timerID);
    1.23 +
    1.24 +class ChildTimer
    1.25 +{
    1.26 +public:
    1.27 +  /**
    1.28 +   * If initialization failed, ID() will return 0.
    1.29 +   */
    1.30 +  ChildTimer(PluginInstanceChild* instance,
    1.31 +             uint32_t interval,
    1.32 +             bool repeat,
    1.33 +             TimerFunc func);
    1.34 +  ~ChildTimer() { }
    1.35 +
    1.36 +  uint32_t ID() const { return mID; }
    1.37 +
    1.38 +  class IDComparator
    1.39 +  {
    1.40 +  public:
    1.41 +    bool Equals(ChildTimer* t, uint32_t id) const {
    1.42 +      return t->ID() == id;
    1.43 +    }
    1.44 +  };
    1.45 +
    1.46 +private:
    1.47 +  PluginInstanceChild* mInstance;
    1.48 +  TimerFunc mFunc;
    1.49 +  bool mRepeating;
    1.50 +  uint32_t mID;
    1.51 +  base::RepeatingTimer<ChildTimer> mTimer;
    1.52 +
    1.53 +  void Run();
    1.54 +
    1.55 +  static uint32_t gNextTimerID;
    1.56 +};
    1.57 +
    1.58 +} // namespace plugins
    1.59 +} // namespace mozilla
    1.60 +
    1.61 +#endif // mozilla_plugins_ChildTimer_h

mercurial