DeviceOrientationController.h [plain text]
#ifndef DeviceOrientationController_h
#define DeviceOrientationController_h
#include "DOMWindow.h"
#include "Timer.h"
#include <wtf/HashCountedSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class DeviceOrientation;
class DeviceOrientationClient;
class Page;
class DeviceOrientationController {
WTF_MAKE_NONCOPYABLE(DeviceOrientationController);
public:
DeviceOrientationController(Page*, DeviceOrientationClient*);
~DeviceOrientationController();
static PassOwnPtr<DeviceOrientationController> create(DeviceOrientationClient* client)
{
return adoptPtr(new DeviceOrientationController(0, client));
}
void suspendUpdates();
void resumeUpdates();
void addListener(DOMWindow*);
void removeListener(DOMWindow*);
void removeAllListeners(DOMWindow*);
void didChangeDeviceOrientation(DeviceOrientation*);
bool isActive() { return !m_listeners.isEmpty(); }
private:
void timerFired(Timer<DeviceOrientationController>*);
Page* m_page;
DeviceOrientationClient* m_client;
typedef HashCountedSet<RefPtr<DOMWindow> > ListenersCountedSet;
ListenersCountedSet m_listeners;
typedef HashSet<RefPtr<DOMWindow> > ListenersSet;
ListenersSet m_newListeners;
Timer<DeviceOrientationController> m_timer;
};
}
#endif // DeviceOrientationController_h