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

Unified Diff: device/generic_sensor/platform_sensor_iio.h

Issue 2370343002: [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: changed implementation 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_iio.h
diff --git a/device/generic_sensor/platform_sensor_iio.h b/device/generic_sensor/platform_sensor_iio.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d40049babae6fee19185f503194ae3b8074b01e
--- /dev/null
+++ b/device/generic_sensor/platform_sensor_iio.h
@@ -0,0 +1,56 @@
+// 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_IIO_H_
+#define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_IIO_H_
+
+#include "device/generic_sensor/platform_sensor.h"
+
+#include "base/timer/timer.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
+
+namespace device {
+
+class PlatformSensorIio : public PlatformSensor {
+ public:
+ PlatformSensorIio(
+ mojom::SensorType type,
+ mojo::ScopedSharedBufferMapping mapping,
+ PlatformSensorProvider* provider,
+ scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner);
+
+ virtual void UpdateReading() = 0;
Mikhail 2016/10/11 14:46:47 rename to 'PollForReadingData()'. Can it be protec
maksims (do not use this acc) 2016/10/14 12:31:45 Done.
+
+ protected:
+ ~PlatformSensorIio() override;
+ bool StartSensor(const PlatformSensorConfiguration& configuration) override;
+ void StopSensor() override;
+ bool CheckSensorConfiguration(
+ const PlatformSensorConfiguration& configuration) override;
+
+ void OnSensorReadFailed();
+
+ // Task runner that is used to poll sensor data from
+ // sensor files.
+ scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_;
+
+ private:
+ void BeginPoll(const PlatformSensorConfiguration& configuration);
+ void StopPoll();
+ void OnStop();
+
+ // Owned timer to be deleted on polling thread.
+ base::RepeatingTimer* timer_;
+
+ base::WeakPtrFactory<PlatformSensorIio> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorIio);
+};
+
+} // namespace device
+
+#endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_IIO_H_

Powered by Google App Engine
This is Rietveld 408576698