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

Unified Diff: third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h

Issue 1892083002: Generic Sensor API : Ambient Light Sensor API. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: 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

Powered by Google App Engine
This is Rietveld 408576698