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

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: add stopUpdating in destructor of BatteryManager. Created 6 years, 6 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..ea6b76ea8a502ff1b6c67e353a56b9617fc75ebe 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";
@@ -51,55 +44,31 @@ bool DeviceLightController::hasLastData()
return DeviceLightDispatcher::instance().latestDeviceLightData() >= 0;
}
-PassRefPtrWillBeRawPtr<Event> DeviceLightController::getLastEvent()
-{
- return DeviceLightEvent::create(EventTypeNames::devicelight,
- DeviceLightDispatcher::instance().latestDeviceLightData());
-}
-
void DeviceLightController::registerWithDispatcher()
{
- DeviceLightDispatcher::instance().addDeviceLightController(this);
+ DeviceLightDispatcher::instance().addController(this);
}
void DeviceLightController::unregisterWithDispatcher()
{
- DeviceLightDispatcher::instance().removeDeviceLightController(this);
-}
-
-bool DeviceLightController::isNullEvent(Event* event)
-{
- DeviceLightEvent* lightEvent = toDeviceLightEvent(event);
- return lightEvent->value() == std::numeric_limits<double>::infinity();
-}
-
-Document* DeviceLightController::document()
-{
- return &m_document;
+ DeviceLightDispatcher::instance().removeController(this);
}
-void DeviceLightController::didAddEventListener(DOMWindow* window, const AtomicString& eventType)
+PassRefPtrWillBeRawPtr<Event> DeviceLightController::lastEvent() const
{
- if (eventType == EventTypeNames::devicelight && RuntimeEnabledFeatures::deviceLightEnabled()) {
- if (page() && page()->visibilityState() == PageVisibilityStateVisible)
- startUpdating();
- m_hasEventListener = true;
- }
+ return DeviceLightEvent::create(EventTypeNames::devicelight,
+ DeviceLightDispatcher::instance().latestDeviceLightData());
}
-void DeviceLightController::didRemoveEventListener(DOMWindow* window, const AtomicString& eventType)
+bool DeviceLightController::isNullEvent(Event* event) const
{
- if (eventType != EventTypeNames::devicelight || window->hasEventListeners(EventTypeNames::devicelight))
- return;
-
- stopUpdating();
- m_hasEventListener = false;
+ DeviceLightEvent* lightEvent = toDeviceLightEvent(event);
+ return lightEvent->value() == std::numeric_limits<double>::infinity();
}
-void DeviceLightController::didRemoveAllEventListeners(DOMWindow* window)
+const AtomicString& DeviceLightController::eventTypeName() const
{
- stopUpdating();
- m_hasEventListener = false;
+ return EventTypeNames::devicelight;
}
} // namespace WebCore
« no previous file with comments | « Source/modules/device_light/DeviceLightController.h ('k') | Source/modules/device_light/DeviceLightDispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698