Index: device/generic_sensor/platform_sensor_ambient_light_iio.h |
diff --git a/device/generic_sensor/platform_sensor_ambient_light_iio.h b/device/generic_sensor/platform_sensor_ambient_light_iio.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7684842b16ca97671e661a46bd1003b371b6748e |
--- /dev/null |
+++ b/device/generic_sensor/platform_sensor_ambient_light_iio.h |
@@ -0,0 +1,57 @@ |
+// 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 DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_IIO_H_ |
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_IIO_H_ |
+ |
+#include "base/memory/ref_counted.h" |
+#include "device/generic_sensor/ambient_light_reader_iio.h" |
+#include "device/generic_sensor/polling_platform_sensor.h" |
+ |
+namespace device { |
+ |
+class PlatformSensorAmbientLightIio : public PollingPlatformSensor { |
+ public: |
+ // Factory method. |
+ static scoped_refptr<PlatformSensor> CreateSensor( |
+ mojom::SensorType type, |
+ mojo::ScopedSharedBufferMapping mapping, |
+ PlatformSensorProvider* provider, |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
+ |
+ // PollingPlatformSensor implements: |
+ void UpdateReading() override; |
+ |
+ // PlatformSensor implements: |
+ mojom::ReportingMode GetReportingMode() override; |
+ |
+ bool sensor_exists() const { return sensor_exists_; } |
+ |
+ protected: |
+ // PlatformSensor implements: |
+ ~PlatformSensorAmbientLightIio() override; |
+ bool CheckSensorConfiguration( |
+ const PlatformSensorConfiguration& configuration) override; |
+ PlatformSensorConfiguration GetDefaultConfiguration() override; |
+ |
+ private: |
+ PlatformSensorAmbientLightIio( |
+ mojom::SensorType type, |
+ mojo::ScopedSharedBufferMapping mapping, |
+ PlatformSensorProvider* provider, |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
+ |
+ void OnSensorReadFailed(); |
+ |
+ double lux_value_; |
+ bool sensor_exists_; |
+ std::unique_ptr<AmbientLightSensorReaderIio> ambient_light_reader_; |
+ base::WeakPtrFactory<PlatformSensorAmbientLightIio> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorAmbientLightIio); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_IIO_H_ |