Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1995)

Unified Diff: Source/modules/device_orientation/DeviceMotionController.h

Issue 14460010: Implement the Blink part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed comments and removed reduntant core/platform layer classes Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/device_orientation/DeviceMotionController.h
diff --git a/Source/modules/device_orientation/DeviceMotionController.h b/Source/modules/device_orientation/DeviceMotionController.h
index f215c4805249b6020d5b56b5776fde95532a1e92..685e39a2b16d9ff548f7779a1d795f72c597e446 100644
--- a/Source/modules/device_orientation/DeviceMotionController.h
+++ b/Source/modules/device_orientation/DeviceMotionController.h
@@ -27,33 +27,58 @@
#ifndef DeviceMotionController_h
#define DeviceMotionController_h
-#include "core/page/DeviceController.h"
+#include "core/dom/Event.h"
+#include "core/page/DOMWindow.h"
+#include "core/platform/RefCountedSupplement.h"
+#include "core/platform/Timer.h"
+#include <wtf/HashCountedSet.h>
namespace WebCore {
-class DeviceMotionClient;
class DeviceMotionData;
-class DeviceMotionController : public DeviceController {
+// This class doesn't inherit from DeviceController anymore, which is a temporary solution.
+// Once the device orientation switches to the client-less design, move some of the
+// methods in this class to the DeviceController.
+class DeviceMotionController : public RefCountedSupplement<Page, DeviceMotionController> {
+
public:
- ~DeviceMotionController() { };
+ virtual ~DeviceMotionController();
- static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*);
+ static PassRefPtr<DeviceMotionController> create();
void didChangeDeviceMotion(DeviceMotionData*);
- DeviceMotionClient* deviceMotionClient();
- virtual bool hasLastData() OVERRIDE;
- virtual PassRefPtr<Event> getLastEvent() OVERRIDE;
+ virtual bool hasLastData();
+ virtual PassRefPtr<Event> getLastEvent();
static const char* supplementName();
static DeviceMotionController* from(Page*);
static bool isActiveAt(Page*);
+ // FIXME move these methods to DeviceController
abarth-chromium 2013/05/06 17:04:17 FIXME -> FIXME:
timvolodine 2013/05/07 15:40:53 Done.
+ void dispatchDeviceEvent(const PassRefPtr<Event>);
+ bool isActive() { return !m_listeners.isEmpty(); }
+
+ void addDeviceEventListener(DOMWindow*);
+ void removeDeviceEventListener(DOMWindow*);
+ void removeAllDeviceEventListeners(DOMWindow*);
+
private:
- explicit DeviceMotionController(DeviceMotionClient*);
+ DeviceMotionController() : m_timer(this, &DeviceMotionController::fireDeviceEvent) { }
+
+ void startUpdating();
+ void stopUpdating();
+ void fireDeviceEvent(Timer<DeviceMotionController>*);
+ void dispatchEventToActiveDocuments(Vector<RefPtr<DOMWindow> >&, const PassRefPtr<Event>);
+
+ HashCountedSet<RefPtr<DOMWindow> > m_listeners;
+ HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners;
+ Timer<DeviceMotionController> m_timer;
};
+void provideDeviceMotionTo(Page*);
+
} // namespace WebCore
#endif // DeviceMotionController_h

Powered by Google App Engine
This is Rietveld 408576698