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

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: added unregister in destructor of DeviceMotionController 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..aa05319d29159dfd8382a2f4361902dc55f0b32f 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,55 @@
#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 {
+class DeviceMotionController : public RefCountedSupplement<Page, DeviceMotionController> {
Peter Beverloo 2013/04/17 19:08:23 We don't inherit from DeviceController anymore. Is
timvolodine 2013/04/18 12:37:38 Done.
+
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 void startUpdating();
- virtual void stopUpdating();
+ static const char* supplementName();
+ static DeviceMotionController* from(Page*);
+ static bool isActiveAt(Page*);
-// -------------------------------------------------
+ // FIXME move these methods to DeviceController once the device orientation
+ // switches to the client-less design.
+ void dispatchDeviceEvent(PassRefPtr<Event>);
Peter Beverloo 2013/04/17 19:08:23 Can we add the "const" modifier to the argument?
timvolodine 2013/04/18 12:37:38 Done.
+ bool isActive() { return !m_listeners.isEmpty(); }
- void addDeviceEventListener(DOMWindow*) OVERRIDE;
- void removeDeviceEventListener(DOMWindow*) OVERRIDE;
- void removeAllDeviceEventListeners(DOMWindow*) OVERRIDE;
+ virtual void addDeviceEventListener(DOMWindow*) OVERRIDE;
+ virtual void removeDeviceEventListener(DOMWindow*) OVERRIDE;
+ virtual void removeAllDeviceEventListeners(DOMWindow*) OVERRIDE;
-// 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>*);
+
+ HashCountedSet<RefPtr<DOMWindow> > m_listeners;
+ HashCountedSet<RefPtr<DOMWindow> > m_lastEventListeners;
+ Timer<DeviceMotionController> m_timer;
};
+void provideDeviceMotionTo(Page*);
Peter Beverloo 2013/04/17 19:08:23 It's very unfortunate that we still need this. I s
timvolodine 2013/04/18 12:37:38 yes, agree this is not very clean. But this is how
+
} // namespace WebCore
#endif // DeviceMotionController_h

Powered by Google App Engine
This is Rietveld 408576698