Commit 7d1235f3 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert IsolatedXRGamepadProviderFactory to new Mojo types

This CL converts IsolatedXRGamepadProviderFactoryPtr and
Binding<IsolatedXRGamepadProviderFactory> in chrome and
device to the new Mojo type, and uses
pending_remote<IsolatedXRGamepadProviderFactory> in
isolated_xr_service.mojom.

Bug: 955171
Change-Id: I109a2197c8e02bdd7908402837284f9f2c45970c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847233
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#704582}
parent 7f04e1dc
...@@ -38,7 +38,8 @@ bool IsolatedVRDeviceProvider::Initialized() { ...@@ -38,7 +38,8 @@ bool IsolatedVRDeviceProvider::Initialized() {
void IsolatedVRDeviceProvider::OnDeviceAdded( void IsolatedVRDeviceProvider::OnDeviceAdded(
device::mojom::XRRuntimePtr device, device::mojom::XRRuntimePtr device,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory, mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory,
device::mojom::XRCompositorHostPtr compositor_host, device::mojom::XRCompositorHostPtr compositor_host,
device::mojom::XRDeviceId device_id) { device::mojom::XRDeviceId device_id) {
add_device_callback_.Run(device_id, nullptr, std::move(device)); add_device_callback_.Run(device_id, nullptr, std::move(device));
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "device/vr/public/mojom/isolated_xr_service.mojom.h" #include "device/vr/public/mojom/isolated_xr_service.mojom.h"
#include "device/vr/vr_device.h" #include "device/vr/vr_device.h"
#include "device/vr/vr_device_provider.h" #include "device/vr/vr_device_provider.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -39,7 +40,8 @@ class IsolatedVRDeviceProvider ...@@ -39,7 +40,8 @@ class IsolatedVRDeviceProvider
// IsolatedXRRuntimeProviderClient // IsolatedXRRuntimeProviderClient
void OnDeviceAdded( void OnDeviceAdded(
device::mojom::XRRuntimePtr device, device::mojom::XRRuntimePtr device,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory, mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory,
device::mojom::XRCompositorHostPtr compositor_host, device::mojom::XRCompositorHostPtr compositor_host,
device::mojom::XRDeviceId device_id) override; device::mojom::XRDeviceId device_id) override;
void OnDeviceRemoved(device::mojom::XRDeviceId id) override; void OnDeviceRemoved(device::mojom::XRDeviceId id) override;
......
...@@ -70,7 +70,8 @@ GamepadSource GamepadSourceFromDeviceId(device::mojom::XRDeviceId id) { ...@@ -70,7 +70,8 @@ GamepadSource GamepadSourceFromDeviceId(device::mojom::XRDeviceId id) {
IsolatedGamepadDataFetcher::Factory::Factory( IsolatedGamepadDataFetcher::Factory::Factory(
device::mojom::XRDeviceId display_id, device::mojom::XRDeviceId display_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory) mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
factory)
: display_id_(display_id), factory_(std::move(factory)) {} : display_id_(display_id), factory_(std::move(factory)) {}
IsolatedGamepadDataFetcher::Factory::~Factory() {} IsolatedGamepadDataFetcher::Factory::~Factory() {}
...@@ -291,7 +292,8 @@ void IsolatedGamepadDataFetcher::Factory::RemoveGamepad( ...@@ -291,7 +292,8 @@ void IsolatedGamepadDataFetcher::Factory::RemoveGamepad(
void IsolatedGamepadDataFetcher::Factory::AddGamepad( void IsolatedGamepadDataFetcher::Factory::AddGamepad(
device::mojom::XRDeviceId device_id, device::mojom::XRDeviceId device_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory) { mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory) {
if (!IsValidDeviceId(device_id)) if (!IsValidDeviceId(device_id))
return; return;
......
...@@ -18,19 +18,21 @@ class IsolatedGamepadDataFetcher : public GamepadDataFetcher { ...@@ -18,19 +18,21 @@ class IsolatedGamepadDataFetcher : public GamepadDataFetcher {
class DEVICE_VR_EXPORT Factory : public GamepadDataFetcherFactory { class DEVICE_VR_EXPORT Factory : public GamepadDataFetcherFactory {
public: public:
Factory(device::mojom::XRDeviceId display_id, Factory(device::mojom::XRDeviceId display_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory); mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
factory);
~Factory() override; ~Factory() override;
std::unique_ptr<GamepadDataFetcher> CreateDataFetcher() override; std::unique_ptr<GamepadDataFetcher> CreateDataFetcher() override;
GamepadSource source() override; GamepadSource source() override;
static void AddGamepad( static void AddGamepad(
device::mojom::XRDeviceId device_id, device::mojom::XRDeviceId device_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory); mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory);
static void RemoveGamepad(device::mojom::XRDeviceId device_id); static void RemoveGamepad(device::mojom::XRDeviceId device_id);
private: private:
device::mojom::XRDeviceId display_id_; device::mojom::XRDeviceId display_id_;
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory_; mojo::Remote<device::mojom::IsolatedXRGamepadProviderFactory> factory_;
}; };
IsolatedGamepadDataFetcher( IsolatedGamepadDataFetcher(
......
...@@ -96,7 +96,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id, ...@@ -96,7 +96,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id,
OculusDevice::OculusDevice() OculusDevice::OculusDevice()
: VRDeviceBase(mojom::XRDeviceId::OCULUS_DEVICE_ID), : VRDeviceBase(mojom::XRDeviceId::OCULUS_DEVICE_ID),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this), compositor_host_binding_(this),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
render_loop_ = std::make_unique<OculusRenderLoop>(); render_loop_ = std::make_unique<OculusRenderLoop>();
...@@ -112,10 +111,9 @@ bool OculusDevice::IsApiAvailable() { ...@@ -112,10 +111,9 @@ bool OculusDevice::IsApiAvailable() {
return result.IsOculusServiceRunning; return result.IsOculusServiceRunning;
} }
mojom::IsolatedXRGamepadProviderFactoryPtr OculusDevice::BindGamepadFactory() { mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
mojom::IsolatedXRGamepadProviderFactoryPtr ret; OculusDevice::BindGamepadFactory() {
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret)); return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
return ret;
} }
mojom::XRCompositorHostPtr OculusDevice::BindCompositorHost() { mojom::XRCompositorHostPtr OculusDevice::BindCompositorHost() {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "device/vr/vr_device_base.h" #include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h" #include "third_party/libovr/src/Include/OVR_CAPI.h"
...@@ -43,7 +44,8 @@ class DEVICE_VR_EXPORT OculusDevice ...@@ -43,7 +44,8 @@ class DEVICE_VR_EXPORT OculusDevice
bool IsAvailable(); bool IsAvailable();
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory(); mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost(); mojom::XRCompositorHostPtr BindCompositorHost();
private: private:
...@@ -74,8 +76,8 @@ class DEVICE_VR_EXPORT OculusDevice ...@@ -74,8 +76,8 @@ class DEVICE_VR_EXPORT OculusDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{ mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this}; this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory> mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_; gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_; mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_; mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
...@@ -124,7 +124,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(vr::IVRSystem* vr_system, ...@@ -124,7 +124,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(vr::IVRSystem* vr_system,
OpenVRDevice::OpenVRDevice() OpenVRDevice::OpenVRDevice()
: VRDeviceBase(device::mojom::XRDeviceId::OPENVR_DEVICE_ID), : VRDeviceBase(device::mojom::XRDeviceId::OPENVR_DEVICE_ID),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this) { compositor_host_binding_(this) {
render_loop_ = std::make_unique<OpenVRRenderLoop>(); render_loop_ = std::make_unique<OpenVRRenderLoop>();
...@@ -139,10 +138,9 @@ bool OpenVRDevice::IsApiAvailable() { ...@@ -139,10 +138,9 @@ bool OpenVRDevice::IsApiAvailable() {
return vr::VR_IsRuntimeInstalled(); return vr::VR_IsRuntimeInstalled();
} }
mojom::IsolatedXRGamepadProviderFactoryPtr OpenVRDevice::BindGamepadFactory() { mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
mojom::IsolatedXRGamepadProviderFactoryPtr ret; OpenVRDevice::BindGamepadFactory() {
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret)); return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
return ret;
} }
mojom::XRCompositorHostPtr OpenVRDevice::BindCompositorHost() { mojom::XRCompositorHostPtr OpenVRDevice::BindCompositorHost() {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "device/vr/vr_device_base.h" #include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace device { namespace device {
...@@ -49,7 +50,8 @@ class DEVICE_VR_EXPORT OpenVRDevice ...@@ -49,7 +50,8 @@ class DEVICE_VR_EXPORT OpenVRDevice
bool IsAvailable(); bool IsAvailable();
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory(); mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost(); mojom::XRCompositorHostPtr BindCompositorHost();
private: private:
...@@ -78,8 +80,8 @@ class DEVICE_VR_EXPORT OpenVRDevice ...@@ -78,8 +80,8 @@ class DEVICE_VR_EXPORT OpenVRDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{ mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this}; this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory> mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_; gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_; mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_; mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
...@@ -86,7 +86,6 @@ bool OpenXrDevice::IsApiAvailable() { ...@@ -86,7 +86,6 @@ bool OpenXrDevice::IsApiAvailable() {
OpenXrDevice::OpenXrDevice() OpenXrDevice::OpenXrDevice()
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID), : VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this), compositor_host_binding_(this),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId())); SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
...@@ -101,10 +100,9 @@ OpenXrDevice::~OpenXrDevice() { ...@@ -101,10 +100,9 @@ OpenXrDevice::~OpenXrDevice() {
} }
} }
mojom::IsolatedXRGamepadProviderFactoryPtr OpenXrDevice::BindGamepadFactory() { mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
mojom::IsolatedXRGamepadProviderFactoryPtr ret; OpenXrDevice::BindGamepadFactory() {
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret)); return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
return ret;
} }
mojom::XRCompositorHostPtr OpenXrDevice::BindCompositorHost() { mojom::XRCompositorHostPtr OpenXrDevice::BindCompositorHost() {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h" #include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace device { namespace device {
...@@ -34,7 +35,8 @@ class DEVICE_VR_EXPORT OpenXrDevice ...@@ -34,7 +35,8 @@ class DEVICE_VR_EXPORT OpenXrDevice
mojom::XRRuntimeSessionOptionsPtr options, mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) override; mojom::XRRuntime::RequestSessionCallback callback) override;
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory(); mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost(); mojom::XRCompositorHostPtr BindCompositorHost();
private: private:
...@@ -62,8 +64,8 @@ class DEVICE_VR_EXPORT OpenXrDevice ...@@ -62,8 +64,8 @@ class DEVICE_VR_EXPORT OpenXrDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{ mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this}; this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory> mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_; gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_; mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_; mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
...@@ -198,7 +198,7 @@ interface IsolatedXRRuntimeProviderClient { ...@@ -198,7 +198,7 @@ interface IsolatedXRRuntimeProviderClient {
// Called when runtimes are initially enumerated, or when devices are later // Called when runtimes are initially enumerated, or when devices are later
// attached and become available. // attached and become available.
OnDeviceAdded(XRRuntime runtime, OnDeviceAdded(XRRuntime runtime,
IsolatedXRGamepadProviderFactory gamepad_factory, pending_remote<IsolatedXRGamepadProviderFactory> gamepad_factory,
XRCompositorHost compositor_host, XRCompositorHost compositor_host,
device.mojom.XRDeviceId device_id); device.mojom.XRDeviceId device_id);
......
...@@ -63,7 +63,6 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) { ...@@ -63,7 +63,6 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
MixedRealityDevice::MixedRealityDevice() MixedRealityDevice::MixedRealityDevice()
: VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID), : VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this) { compositor_host_binding_(this) {
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId())); SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
} }
...@@ -72,11 +71,9 @@ MixedRealityDevice::~MixedRealityDevice() { ...@@ -72,11 +71,9 @@ MixedRealityDevice::~MixedRealityDevice() {
Shutdown(); Shutdown();
} }
mojom::IsolatedXRGamepadProviderFactoryPtr mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
MixedRealityDevice::BindGamepadFactory() { MixedRealityDevice::BindGamepadFactory() {
mojom::IsolatedXRGamepadProviderFactoryPtr ret; return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret));
return ret;
} }
mojom::XRCompositorHostPtr MixedRealityDevice::BindCompositorHost() { mojom::XRCompositorHostPtr MixedRealityDevice::BindCompositorHost() {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "device/vr/windows/compositor_base.h" #include "device/vr/windows/compositor_base.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace device { namespace device {
...@@ -28,7 +29,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice ...@@ -28,7 +29,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice
MixedRealityDevice(); MixedRealityDevice();
~MixedRealityDevice() override; ~MixedRealityDevice() override;
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory(); mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost(); mojom::XRCompositorHostPtr BindCompositorHost();
private: private:
...@@ -59,8 +61,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice ...@@ -59,8 +61,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice
std::unique_ptr<XRCompositorCommon> render_loop_; std::unique_ptr<XRCompositorCommon> render_loop_;
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory> mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_; gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_; mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_; mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment