michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_plugins_ChildTimer_h michael@0: #define mozilla_plugins_ChildTimer_h michael@0: michael@0: #include "PluginMessageUtils.h" michael@0: #include "npapi.h" michael@0: #include "base/timer.h" michael@0: michael@0: namespace mozilla { michael@0: namespace plugins { michael@0: michael@0: class PluginInstanceChild; michael@0: typedef void (*TimerFunc)(NPP npp, uint32_t timerID); michael@0: michael@0: class ChildTimer michael@0: { michael@0: public: michael@0: /** michael@0: * If initialization failed, ID() will return 0. michael@0: */ michael@0: ChildTimer(PluginInstanceChild* instance, michael@0: uint32_t interval, michael@0: bool repeat, michael@0: TimerFunc func); michael@0: ~ChildTimer() { } michael@0: michael@0: uint32_t ID() const { return mID; } michael@0: michael@0: class IDComparator michael@0: { michael@0: public: michael@0: bool Equals(ChildTimer* t, uint32_t id) const { michael@0: return t->ID() == id; michael@0: } michael@0: }; michael@0: michael@0: private: michael@0: PluginInstanceChild* mInstance; michael@0: TimerFunc mFunc; michael@0: bool mRepeating; michael@0: uint32_t mID; michael@0: base::RepeatingTimer mTimer; michael@0: michael@0: void Run(); michael@0: michael@0: static uint32_t gNextTimerID; michael@0: }; michael@0: michael@0: } // namespace plugins michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_plugins_ChildTimer_h