1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
content / services / isolated_xr_device / xr_runtime_provider.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SERVICES_ISOLATED_XR_DEVICE_XR_RUNTIME_PROVIDER_H_
#define CONTENT_SERVICES_ISOLATED_XR_DEVICE_XR_RUNTIME_PROVIDER_H_
#include <memory>
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "device/vr/buildflags/buildflags.h"
#include "device/vr/public/mojom/isolated_xr_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#if BUILDFLAG(ENABLE_OPENXR) && BUILDFLAG(IS_WIN)
#include "components/viz/common/gpu/context_provider.h"
#include "device/vr/openxr/context_provider_callbacks.h"
#include "device/vr/openxr/windows/openxr_platform_helper_windows.h"
#include "services/viz/public/cpp/gpu/gpu.h"
#endif
#if BUILDFLAG(ENABLE_OPENXR) && BUILDFLAG(IS_WIN)
namespace device {
class OpenXrDevice;
} // namespace device
namespace viz {
class Gpu;
} // namespace viz
#endif
class IsolatedXRRuntimeProvider final
: public device::mojom::IsolatedXRRuntimeProvider {
public:
explicit IsolatedXRRuntimeProvider(
mojo::PendingRemote<device::mojom::XRDeviceServiceHost>
device_service_host,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
~IsolatedXRRuntimeProvider() override;
void RequestDevices(
mojo::PendingRemote<device::mojom::IsolatedXRRuntimeProviderClient>
client) override;
enum class RuntimeStatus;
private:
void PollForDeviceChanges();
void SetupPollingForDeviceChanges();
#if BUILDFLAG(ENABLE_OPENXR) && BUILDFLAG(IS_WIN)
bool IsOpenXrHardwareAvailable();
void SetOpenXrRuntimeStatus(RuntimeStatus status);
void CreateContextProviderAsync(
VizContextProviderCallback viz_context_provider_callback);
bool should_check_openxr_ = false;
// Must outlive OpenXrDevice
std::unique_ptr<device::OpenXrPlatformHelperWindows> openxr_platform_helper_;
std::unique_ptr<device::OpenXrDevice> openxr_device_;
std::unique_ptr<viz::Gpu> viz_gpu_;
#endif
mojo::Remote<device::mojom::XRDeviceServiceHost> device_service_host_;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
mojo::Remote<device::mojom::IsolatedXRRuntimeProviderClient> client_;
base::WeakPtrFactory<IsolatedXRRuntimeProvider> weak_ptr_factory_{this};
};
#endif // CONTENT_SERVICES_ISOLATED_XR_DEVICE_XR_RUNTIME_PROVIDER_H_