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