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_SENSORS_DEVICE_SENSOR_HOST_H_ | |
6 #define DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/shared_memory.h" | |
10 #include "device/sensors/device_sensors_consts.h" | |
11 #include "device/sensors/public/interfaces/motion.mojom.h" | |
12 #include "device/sensors/public/interfaces/orientation.mojom.h" | |
13 #include "mojo/public/cpp/bindings/interface_request.h" | |
14 | |
15 namespace device { | |
16 | |
17 // A base class for device sensor related mojo interface implementations. | |
18 template <typename MojoInterface, ConsumerType consumer_type> | |
19 class DeviceSensorHost : NON_EXPORTED_BASE(public MojoInterface) { | |
20 public: | |
21 static void Create(mojo::InterfaceRequest<MojoInterface> request); | |
22 | |
23 // All methods below to be called on the IO thread. | |
24 ~DeviceSensorHost() override; | |
25 | |
26 private: | |
27 DeviceSensorHost(); | |
28 | |
29 void StartPolling( | |
30 typename MojoInterface::StartPollingCallback callback) override; | |
31 void StopPolling() override; | |
32 | |
33 bool is_started_; | |
34 | |
35 base::ThreadChecker thread_checker_; | |
36 | |
37 DISALLOW_COPY_AND_ASSIGN(DeviceSensorHost); | |
38 }; | |
39 | |
40 using DeviceMotionHost = | |
41 DeviceSensorHost<device::mojom::MotionSensor, CONSUMER_TYPE_MOTION>; | |
42 using DeviceOrientationHost = DeviceSensorHost<device::mojom::OrientationSensor, | |
43 CONSUMER_TYPE_ORIENTATION>; | |
44 using DeviceOrientationAbsoluteHost = | |
45 DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, | |
46 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; | |
47 | |
48 } // namespace device | |
49 | |
50 #endif // DEVICE_SENSORS_DEVICE_SENSOR_HOST_H_ | |
OLD | NEW |