OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ | |
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ | |
7 | |
8 #include "device/generic_sensor/platform_sensor.h" | |
9 | |
10 namespace base { | |
11 class SingleThreadTaskRunner; | |
12 } | |
13 | |
14 namespace device { | |
15 | |
16 class SensorReader; | |
17 struct SensorInfoLinux; | |
18 | |
19 class PlatformSensorLinux : public PlatformSensor { | |
20 public: | |
21 PlatformSensorLinux( | |
22 mojom::SensorType type, | |
23 mojo::ScopedSharedBufferMapping mapping, | |
24 PlatformSensorProvider* provider, | |
25 const SensorInfoLinux* sensor_device, | |
26 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner); | |
27 | |
28 mojom::ReportingMode GetReportingMode() override; | |
29 | |
30 // Called by a sensor reader. Takes new readings. | |
31 void UpdatePlatformSensorReading(SensorReading reading); | |
32 | |
33 // Called by a sensor reader if an error occurs. | |
34 void NotifyPlatformSensorError(); | |
35 | |
36 protected: | |
37 ~PlatformSensorLinux() override; | |
38 bool StartSensor(const PlatformSensorConfiguration& configuration) override; | |
39 void StopSensor() override; | |
40 bool CheckSensorConfiguration( | |
41 const PlatformSensorConfiguration& configuration) override; | |
42 PlatformSensorConfiguration GetDefaultConfiguration() override; | |
43 | |
44 private: | |
45 const PlatformSensorConfiguration default_configuration_; | |
46 const mojom::ReportingMode reporting_mode_; | |
47 | |
48 scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_; | |
49 | |
50 // A sensor reader that reads values from sensor files | |
51 // and stores them to a SensorReading structure. | |
52 std::unique_ptr<SensorReader> sensor_reader_; | |
53 | |
54 // Stores previously read values that are used to | |
55 // determine whether the recent values are changed | |
56 // and IPC can be notified that updates are available. | |
57 SensorReading old_values_; | |
58 | |
59 base::WeakPtrFactory<PlatformSensorLinux> weak_factory_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(PlatformSensorLinux); | |
62 }; | |
63 | |
64 } // namespace device | |
65 | |
66 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_LINUX_H_ | |
OLD | NEW |