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

Unified Diff: Source/WebCore/dom/DeviceMotionController.h

Issue 13866007: WebKit & WebCore part of the device motion implementation using the platform layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@devicemotion-webcore
Patch Set: fixed Eric's comments. 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/WebCore/dom/DeviceMotionController.h
diff --git a/Source/WebCore/dom/DeviceMotionController.h b/Source/WebCore/dom/DeviceMotionController.h
index eac2313a72fb0337dd9e57d978d8c4d731fb8a1e..5403de546b2bac4b116f2e5e9e7d6f43bafc0d9a 100644
--- a/Source/WebCore/dom/DeviceMotionController.h
+++ b/Source/WebCore/dom/DeviceMotionController.h
@@ -1,29 +1,25 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@@ -31,42 +27,58 @@
#ifndef DeviceMotionController_h
#define DeviceMotionController_h
-#include "DeviceController.h"
+#include "DOMWindow.h"
+#include "Event.h"
+#include "RefCountedSupplement.h"
+#include "Timer.h"
+#include <wtf/HashCountedSet.h>
namespace WebCore {
class DeviceMotionData;
-class DeviceMotionController : public DeviceController {
+// FIXME: 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:
- virtual ~DeviceMotionController() { };
+ virtual ~DeviceMotionController();
- static DeviceMotionController& shared();
+ static PassRefPtr<DeviceMotionController> create();
void didChangeDeviceMotion(DeviceMotionData*);
- virtual bool hasLastData() OVERRIDE;
- virtual PassRefPtr<Event> getLastEvent() OVERRIDE;
- bool isActiveAt(Page* page) { return m_activePages.contains(page); }
+ virtual bool hasLastData();
+ virtual PassRefPtr<Event> getLastEvent();
- virtual void startUpdating();
- virtual void stopUpdating();
+ static const char* supplementName();
+ static DeviceMotionController* from(Page*);
+ static bool isActiveAt(Page*);
-// -------------------------------------------------
+ // FIXME move these methods to DeviceController
+ void dispatchDeviceEvent(const PassRefPtr<Event>);
+ bool isActive() { return !m_listeners.isEmpty(); }
- void addDeviceEventListener(DOMWindow*) OVERRIDE;
- void removeDeviceEventListener(DOMWindow*) OVERRIDE;
- void removeAllDeviceEventListeners(DOMWindow*) OVERRIDE;
+ virtual void addDeviceEventListener(DOMWindow*);
+ virtual void removeDeviceEventListener(DOMWindow*);
+ virtual void removeAllDeviceEventListeners(DOMWindow*);
abarth-chromium 2013/04/23 21:36:26 Are there subclasses of this object? Do these sti
timvolodine 2013/04/24 12:36:03 Done.
-// void dispatchDeviceEvent(PassRefPtr<Event>);
-// bool isActive() { return !m_listeners.isEmpty(); }
-// DeviceClient* client() { return m_client; }
+private:
+ DeviceMotionController() : m_timer(this, &DeviceMotionController::fireDeviceEvent) { }
-protected:
- DeviceMotionController();
- HashCountedSet<Page*> m_activePages;
+ 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;
abarth-chromium 2013/04/23 21:36:26 This is a bad pattern. We shouldn't ref the DOMWi
timvolodine 2013/04/24 12:36:03 Will keep the RefPtr for now, since apparently the
+ Timer<DeviceMotionController> m_timer;
};
+void provideDeviceMotionTo(Page*);
+
} // namespace WebCore
#endif // DeviceMotionController_h

Powered by Google App Engine
This is Rietveld 408576698