Bumping manifests a=b2g-bump
[gecko.git] / dom / plugins / ipc / ChildTimer.h
blob194fa77abde992ad2aba0866d25ae9e0e3a9149c
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
23 public:
24 /**
25 * If initialization failed, ID() will return 0.
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
37 public:
38 bool Equals(ChildTimer* t, uint32_t id) const {
39 return t->ID() == id;
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;
55 } // namespace plugins
56 } // namespace mozilla
58 #endif // mozilla_plugins_ChildTimer_h