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

Unified Diff: Source/modules/device_light/DeviceLightController.cpp

Issue 315573002: Generalize and refactor DeviceSensorEvent* architecture to support multi-event type targets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: similarity=60 Created 6 years, 7 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_light/DeviceLightController.cpp
diff --git a/Source/modules/device_light/DeviceLightController.cpp b/Source/modules/device_light/DeviceLightController.cpp
index 36e09cedfe518ea105e169d6c7817ec3389a9775..6b4adbe673d55d96a04a22ce713e25bf8d4126ec 100644
--- a/Source/modules/device_light/DeviceLightController.cpp
+++ b/Source/modules/device_light/DeviceLightController.cpp
@@ -15,9 +15,7 @@
namespace WebCore {
DeviceLightController::DeviceLightController(Document& document)
- : DeviceSensorEventController(document.page())
- , DOMWindowLifecycleObserver(document.domWindow())
- , m_document(document)
+ : DeviceSingleWindowEventController(document)
{
}
@@ -26,11 +24,6 @@ DeviceLightController::~DeviceLightController()
stopUpdating();
}
-void DeviceLightController::didChangeDeviceLight(double value)
-{
- dispatchDeviceEvent(DeviceLightEvent::create(EventTypeNames::devicelight, value));
-}
-
const char* DeviceLightController::supplementName()
{
return "DeviceLightController";
@@ -46,25 +39,25 @@ DeviceLightController& DeviceLightController::from(Document& document)
return *controller;
}
-bool DeviceLightController::hasLastData()
+bool DeviceLightController::isInvokeInitialUpdate()
{
return DeviceLightDispatcher::instance().latestDeviceLightData() >= 0;
}
-PassRefPtrWillBeRawPtr<Event> DeviceLightController::getLastEvent()
+void DeviceLightController::registerWithDispatcher()
{
- return DeviceLightEvent::create(EventTypeNames::devicelight,
- DeviceLightDispatcher::instance().latestDeviceLightData());
+ DeviceLightDispatcher::instance().addController(this);
}
-void DeviceLightController::registerWithDispatcher()
+void DeviceLightController::unregisterWithDispatcher()
{
- DeviceLightDispatcher::instance().addDeviceLightController(this);
+ DeviceLightDispatcher::instance().removeController(this);
}
-void DeviceLightController::unregisterWithDispatcher()
+PassRefPtrWillBeRawPtr<Event> DeviceLightController::getLastEvent()
{
- DeviceLightDispatcher::instance().removeDeviceLightController(this);
+ return DeviceLightEvent::create(EventTypeNames::devicelight,
+ DeviceLightDispatcher::instance().latestDeviceLightData());
}
bool DeviceLightController::isNullEvent(Event* event)
@@ -73,33 +66,9 @@ bool DeviceLightController::isNullEvent(Event* event)
return lightEvent->value() == std::numeric_limits<double>::infinity();
}
-Document* DeviceLightController::document()
+const AtomicString& DeviceLightController::getEventTypeName()
{
- return &m_document;
-}
-
-void DeviceLightController::didAddEventListener(DOMWindow* window, const AtomicString& eventType)
-{
- if (eventType == EventTypeNames::devicelight && RuntimeEnabledFeatures::deviceLightEnabled()) {
- if (page() && page()->visibilityState() == PageVisibilityStateVisible)
- startUpdating();
- m_hasEventListener = true;
- }
-}
-
-void DeviceLightController::didRemoveEventListener(DOMWindow* window, const AtomicString& eventType)
-{
- if (eventType != EventTypeNames::devicelight || window->hasEventListeners(EventTypeNames::devicelight))
- return;
-
- stopUpdating();
- m_hasEventListener = false;
-}
-
-void DeviceLightController::didRemoveAllEventListeners(DOMWindow* window)
-{
- stopUpdating();
- m_hasEventListener = false;
+ return EventTypeNames::devicelight;
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698