Index: third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h |
diff --git a/third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h b/third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8c5146afc4120add048843a158d4a331012fd3e7 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h |
@@ -0,0 +1,49 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef AmbientLightSensorDispatcher_h |
+#define AmbientLightSensorDispatcher_h |
+ |
+#include "core/frame/PlatformEventDispatcher.h" |
+#include "device/sensor/sensor.mojom.h" |
+#include "modules/ModulesExport.h" |
+#include "modules/sensor/AmbientLightSensor.h" |
+#include "modules/sensor/als_reading.h" |
+#include "wtf/OwnPtr.h" |
+ |
+namespace blink { |
+ |
+class MODULES_EXPORT AmbientLightSensorDispatcher final : public GarbageCollectedFinalized<AmbientLightSensorDispatcher>, public PlatformEventDispatcher { |
+ USING_GARBAGE_COLLECTED_MIXIN(AmbientLightSensorDispatcher); |
+ WTF_MAKE_NONCOPYABLE(AmbientLightSensorDispatcher); |
+ |
+public: |
+ static AmbientLightSensorDispatcher& instance(); |
+ |
+ const AmbientLightSensorReadingProxy* latestData() const |
+ { |
+ return m_hasLatestData ? &m_alsReading : nullptr; |
+ } |
+ |
+private: |
+ AmbientLightSensorDispatcher(); |
+ |
+ void queryNextReading(); |
+ void onDidChange(device::AmbientLightSensorReadingPtr); |
+ void updateSensorReading(const AmbientLightSensorReadingProxy&); |
+ void startReading(); |
+ void stopReading(); |
+ |
+ // Inherited from PlatformEventDispatcher. |
+ void startListening() override; |
+ void stopListening() override; |
+ |
+ device::AmbientLightSensorPtr m_lightSensor; |
+ AmbientLightSensorReadingProxy m_alsReading; |
+ bool m_hasLatestData; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // AmbientLightSensorDispatcher_h |