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

Side by Side Diff: device/generic_sensor/platform_sensor_relative_orientation_using_accelerometer.h

Issue 2929603003: Add RELATIVE_ORIENTATION sensor implementation on macOS to //device/generic_sensor (Closed)
Patch Set: updated readme file Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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_RELATIVE_ORIENTATION_USING_ACCELER OMETER_H_
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCELER OMETER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/timer/timer.h"
12 #include "device/generic_sensor/platform_sensor.h"
13
14 namespace device {
15
16 class SensorSharedBufferReader;
17
18 // Implementation of relative orientation PlatformSensor using accelerometer.
19 // This is a single instance object per browser process which is created by
20 // The singleton PlatformSensorProvider. If there are no clients, this instance
21 // is not created.
22 class PlatformSensorRelativeOrientationUsingAccelerometer
23 : public PlatformSensor {
24 public:
25 // Construct a platform sensor of type RELATIVE_ORIENTATION, given a buffer
26 // |mapping| where readings will be written.
27 PlatformSensorRelativeOrientationUsingAccelerometer(
28 mojo::ScopedSharedBufferMapping mapping,
29 PlatformSensorProvider* provider);
30
31 mojom::ReportingMode GetReportingMode() override;
32 PlatformSensorConfiguration GetDefaultConfiguration() override;
33 // Can only be called once, the first time or after a StopSensor call.
34 bool StartSensor(const PlatformSensorConfiguration& configuration) override;
35 void StopSensor() override;
36
37 protected:
38 ~PlatformSensorRelativeOrientationUsingAccelerometer() override;
39 bool CheckSensorConfiguration(
40 const PlatformSensorConfiguration& configuration) override;
41
42 private:
43 void CreateAccelerometerCallback(scoped_refptr<PlatformSensor> accelerometer);
44 void PollForData();
45
46 SensorReading reading_;
47 // Repeating timer for data polling.
48 base::RepeatingTimer timer_;
49 scoped_refptr<PlatformSensor> accelerometer_;
50 std::unique_ptr<SensorSharedBufferReader> accelerometer_reader_;
51
52 DISALLOW_COPY_AND_ASSIGN(PlatformSensorRelativeOrientationUsingAccelerometer);
53 };
54
55 } // namespace device
56
57 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_RELATIVE_ORIENTATION_USING_ACCE LEROMETER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698