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