 Chromium Code Reviews
 Chromium Code Reviews Issue 2370343002:
  [sensors] Ambient light sensor implementation for ChromeOS and Linux.  (Closed)
    
  
    Issue 2370343002:
  [sensors] Ambient light sensor implementation for ChromeOS and Linux.  (Closed) 
  | Index: device/generic_sensor/iio/platform_sensor_utils_iio.h | 
| diff --git a/device/generic_sensor/iio/platform_sensor_utils_iio.h b/device/generic_sensor/iio/platform_sensor_utils_iio.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..f8579d3f18581752643b0c9cadca74f2bcfd958b | 
| --- /dev/null | 
| +++ b/device/generic_sensor/iio/platform_sensor_utils_iio.h | 
| @@ -0,0 +1,40 @@ | 
| +// 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_IIO_PLATFORM_SENSOR_UTILS_IIO_H_ | 
| +#define DEVICE_GENERIC_SENSOR_IIO_PLATFORM_SENSOR_UTILS_IIO_H_ | 
| + | 
| +#include "base/files/file_path.h" | 
| +#include "device/generic_sensor/iio/sensor_data_iio.h" | 
| +#include "device/generic_sensor/public/cpp/sensor_reading.h" | 
| + | 
| +namespace device { | 
| + | 
| +// Generic reader class that reads sensors data from | 
| +// sensors files located in the base iio folder. | 
| +class SensorReader { | 
| 
Mikhail
2016/10/17 10:34:11
needs unit tests
 
darktears
2016/10/17 20:35:29
Potentially tricky. Not all ChromeOS have the afor
 
maksims (do not use this acc)
2016/10/18 06:50:41
There is no problem at all. It's possible to creat
 
maksims (do not use this acc)
2016/10/18 06:50:41
Got it!
 | 
| + public: | 
| + ~SensorReader(); | 
| + | 
| + // Creates a new instance of SensorReader if sensor read files | 
| + // has been found and |sensor_paths_| are set. | 
| + static std::unique_ptr<SensorReader> Create(const SensorDataIio& data); | 
| + | 
| + // Reads sensor values into |*reading| from sensor files | 
| + // specified in |sensor_paths_|. | 
| + bool ReadSensorReading(SensorReading* reading); | 
| + | 
| + private: | 
| + explicit SensorReader(std::vector<base::FilePath> sensor_paths); | 
| + | 
| + // Contains paths to sensor files that are set when | 
| + // Create() is called. | 
| + const std::vector<base::FilePath> sensor_paths_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(SensorReader); | 
| +}; | 
| + | 
| +} // namespace device | 
| + | 
| +#endif // DEVICE_GENERIC_SENSOR_IIO_PLATFORM_SENSOR_UTILS_IIO_H_ |