Home | History | Annotate | Download | only in device_light
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "config.h"
      6 #include "modules/device_light/DeviceLightDispatcher.h"
      7 
      8 #include "modules/device_light/DeviceLightController.h"
      9 #include "public/platform/Platform.h"
     10 
     11 namespace blink {
     12 
     13 DeviceLightDispatcher& DeviceLightDispatcher::instance()
     14 {
     15     DEFINE_STATIC_LOCAL(DeviceLightDispatcher, deviceLightDispatcher, ());
     16     return deviceLightDispatcher;
     17 }
     18 
     19 DeviceLightDispatcher::DeviceLightDispatcher()
     20     : m_lastDeviceLightData(-1)
     21 {
     22 }
     23 
     24 DeviceLightDispatcher::~DeviceLightDispatcher()
     25 {
     26 }
     27 
     28 void DeviceLightDispatcher::startListening()
     29 {
     30     Platform::current()->startListening(WebPlatformEventDeviceLight, this);
     31 }
     32 
     33 void DeviceLightDispatcher::stopListening()
     34 {
     35     Platform::current()->stopListening(WebPlatformEventDeviceLight);
     36     m_lastDeviceLightData = -1;
     37 }
     38 
     39 void DeviceLightDispatcher::didChangeDeviceLight(double value)
     40 {
     41     m_lastDeviceLightData = value;
     42     notifyControllers();
     43 }
     44 
     45 double DeviceLightDispatcher::latestDeviceLightData() const
     46 {
     47     return m_lastDeviceLightData;
     48 }
     49 
     50 } // namespace blink
     51