Chromium Code Reviews| Index: device/generic_sensor/linux/sensor_data_linux.cc |
| diff --git a/device/generic_sensor/linux/sensor_data_linux.cc b/device/generic_sensor/linux/sensor_data_linux.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e39491b67c6cc43b60d6a25df53c2d9dd22ff78 |
| --- /dev/null |
| +++ b/device/generic_sensor/linux/sensor_data_linux.cc |
| @@ -0,0 +1,51 @@ |
| +// 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. |
| + |
| +#include "device/generic_sensor/linux/sensor_data_linux.h" |
| +#include "device/sensors/public/cpp/device_sensors_consts.h" |
| + |
| +namespace device { |
| + |
| +namespace { |
| + |
| +using mojom::SensorType; |
| + |
| +const base::FilePath::CharType* kSensorsBasePath = |
| + FILE_PATH_LITERAL("/sys/bus/iio/devices"); |
| + |
| +const std::string kAmbientLightFileNames[] = { |
|
Ken Rockot(use gerrit already)
2016/11/03 16:14:35
This runs initializers, which are forbidden. Use C
maksims (do not use this acc)
2016/11/04 08:37:33
Oh, thanks! Fixed
|
| + "in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw", |
| + "in_illuminance_raw", "illuminance0_input"}; |
| + |
| +} // namespace |
| + |
| +SensorDataLinux::SensorDataLinux() : base_path_sensor_linux(kSensorsBasePath) {} |
| + |
| +SensorDataLinux::~SensorDataLinux() = default; |
| + |
| +SensorDataLinux::SensorDataLinux(const SensorDataLinux& other) = default; |
| + |
| +bool InitSensorData(SensorType type, SensorDataLinux* data) { |
| + DCHECK(data); |
| + |
| + switch (type) { |
| + case SensorType::AMBIENT_LIGHT: { |
| + std::vector<std::string> file_names( |
| + kAmbientLightFileNames, |
| + kAmbientLightFileNames + arraysize(kAmbientLightFileNames)); |
| + data->sensor_file_names.push_back(std::move(file_names)); |
| + data->reporting_mode = mojom::ReportingMode::ON_CHANGE; |
| + data->default_configuration = |
| + PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz); |
| + break; |
| + } |
| + default: { |
| + NOTIMPLEMENTED(); |
| + return false; |
| + } |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace device |