DeviceMotionController.h [plain text]
#ifndef DeviceMotionController_h
#define DeviceMotionController_h
#include "DOMWindow.h"
#include "Page.h"
#include "Timer.h"
#include <wtf/HashCountedSet.h>
namespace WebCore {
class DeviceMotionData;
class DeviceMotionClient;
class DeviceMotionController : public Supplement<Page> {
public:
~DeviceMotionController();
static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*);
void addListener(DOMWindow*);
void removeListener(DOMWindow*);
void removeAllListeners(DOMWindow*);
void suspendEventsForAllListeners(DOMWindow*);
void resumeEventsForAllListeners(DOMWindow*);
void didChangeDeviceMotion(DeviceMotionData*);
bool isActive() { return !m_listeners.isEmpty(); }
static const AtomicString& supplementName();
static DeviceMotionController* from(Page* page) { return static_cast<DeviceMotionController*>(Supplement<Page>::from(page, supplementName())); }
static bool isActiveAt(Page*);
private:
DeviceMotionController(DeviceMotionClient*);
void timerFired(Timer<DeviceMotionController>*);
DeviceMotionClient* m_client;
typedef HashCountedSet<RefPtr<DOMWindow> > ListenersCountedSet;
ListenersCountedSet m_listeners;
ListenersCountedSet m_suspendedListeners;
typedef HashSet<RefPtr<DOMWindow> > ListenersSet;
ListenersSet m_newListeners;
Timer<DeviceMotionController> m_timer;
};
}
#endif // DeviceMotionController_h