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

Unified Diff: device/generic_sensor/platform_sensor_ambient_light_iio.h

Issue 2370343002: [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: rebased on top of Mihail's cl Created 4 years, 2 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: 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_

Powered by Google App Engine
This is Rietveld 408576698