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

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: re entrancy fix Created 4 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: 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..86cddab32c222ac97c2b7c615f89bdf30d0b7a4b
--- /dev/null
+++ b/third_party/WebKit/Source/modules/sensor/AmbientLightSensorDispatcher.h
@@ -0,0 +1,50 @@
+// 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/als_reading.mojom-blink.h"
+#include "device/sensor/sensor.mojom-blink.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::blink::AmbientLightSensorReadingPtr);
+ void updateSensorReading(const AmbientLightSensorReadingProxy&);
+ void startReading();
+ void stopReading();
+
+ // Inherited from PlatformEventDispatcher.
+ void startListening() override;
+ void stopListening() override;
+
+ device::blink::AmbientLightSensorPtr m_lightSensor;
+ AmbientLightSensorReadingProxy m_alsReading;
+ bool m_hasLatestData;
+};
+
+} // namespace blink
+
+#endif // AmbientLightSensorDispatcher_h

Powered by Google App Engine
This is Rietveld 408576698