Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 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_VR_ORIENTATION_DEVICE_PROVIDER_H |
| 6 | #define DEVICE_VR_ORIENTATION_DEVICE_PROVIDER_H |
| 7 | |
| 8 | #include <memory> |
| 9 | |
| 10 | #include "base/callback_forward.h" |
Alexander Cooper | cb573b0 | 2020-04-21 22:16:35 | [diff] [blame^] | 11 | #include "base/component_export.h" |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 12 | #include "base/macros.h" |
| 13 | #include "device/vr/orientation/orientation_device.h" |
Alexander Cooper | 20e912c7 | 2020-04-20 22:51:28 | [diff] [blame] | 14 | #include "device/vr/public/cpp/vr_device_provider.h" |
Miyoung Shin | 3a4bd17 | 2019-10-15 02:55:01 | [diff] [blame] | 15 | #include "mojo/public/cpp/bindings/pending_remote.h" |
Miyoung Shin | d012ec7 | 2019-09-24 03:10:54 | [diff] [blame] | 16 | #include "mojo/public/cpp/bindings/remote.h" |
Ke He | 31d0bb0 | 2018-02-24 07:16:24 | [diff] [blame] | 17 | #include "services/device/public/mojom/sensor_provider.mojom.h" |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 18 | |
| 19 | namespace device { |
| 20 | |
Alexander Cooper | cb573b0 | 2020-04-21 22:16:35 | [diff] [blame^] | 21 | class COMPONENT_EXPORT(VR_ORIENTATION) VROrientationDeviceProvider |
| 22 | : public VRDeviceProvider { |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 23 | public: |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 24 | explicit VROrientationDeviceProvider( |
| 25 | mojo::PendingRemote<device::mojom::SensorProvider> sensor_provider); |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 26 | ~VROrientationDeviceProvider() override; |
| 27 | |
| 28 | void Initialize( |
Bill Orr | eb42922 | 2018-08-08 21:14:43 | [diff] [blame] | 29 | base::RepeatingCallback<void(mojom::XRDeviceId, |
Bill Orr | be7e1da | 2018-06-30 02:10:14 | [diff] [blame] | 30 | mojom::VRDisplayInfoPtr, |
Miyoung Shin | 3a4bd17 | 2019-10-15 02:55:01 | [diff] [blame] | 31 | mojo::PendingRemote<mojom::XRRuntime>)> |
| 32 | add_device_callback, |
Bill Orr | eb42922 | 2018-08-08 21:14:43 | [diff] [blame] | 33 | base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback, |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 34 | base::OnceClosure initialization_complete) override; |
| 35 | |
| 36 | bool Initialized() override; |
| 37 | |
| 38 | private: |
| 39 | void DeviceInitialized(); |
| 40 | |
| 41 | bool initialized_ = false; |
| 42 | |
Miyoung Shin | d012ec7 | 2019-09-24 03:10:54 | [diff] [blame] | 43 | mojo::Remote<device::mojom::SensorProvider> sensor_provider_; |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 44 | |
| 45 | std::unique_ptr<VROrientationDevice> device_; |
| 46 | |
Miyoung Shin | 3a4bd17 | 2019-10-15 02:55:01 | [diff] [blame] | 47 | base::RepeatingCallback<void(mojom::XRDeviceId, |
| 48 | mojom::VRDisplayInfoPtr, |
| 49 | mojo::PendingRemote<mojom::XRRuntime>)> |
Bill Orr | be7e1da | 2018-06-30 02:10:14 | [diff] [blame] | 50 | add_device_callback_; |
Anna Maria | 114d3505 | 2017-12-08 23:13:29 | [diff] [blame] | 51 | base::OnceClosure initialized_callback_; |
| 52 | |
| 53 | DISALLOW_COPY_AND_ASSIGN(VROrientationDeviceProvider); |
| 54 | }; |
| 55 | |
| 56 | } // namespace device |
| 57 | |
| 58 | #endif // DEVICE_VR_ORIENTATION_DEVICE_PROVIDER_H |