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() {
void IsolatedVRDeviceProvider::OnDeviceAdded(
device::mojom::XRRuntimePtr device,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory,
mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory,
device::mojom::XRCompositorHostPtr compositor_host,
device::mojom::XRDeviceId device_id) {
add_device_callback_.Run(device_id, nullptr, std::move(device));
......
......@@ -9,6 +9,7 @@
#include "device/vr/public/mojom/isolated_xr_service.mojom.h"
#include "device/vr/vr_device.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/remote.h"
......@@ -39,7 +40,8 @@ class IsolatedVRDeviceProvider
// IsolatedXRRuntimeProviderClient
void OnDeviceAdded(
device::mojom::XRRuntimePtr device,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory,
mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory,
device::mojom::XRCompositorHostPtr compositor_host,
device::mojom::XRDeviceId device_id) override;
void OnDeviceRemoved(device::mojom::XRDeviceId id) override;
......
......@@ -70,7 +70,8 @@ GamepadSource GamepadSourceFromDeviceId(device::mojom::XRDeviceId id) {
IsolatedGamepadDataFetcher::Factory::Factory(
device::mojom::XRDeviceId display_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory)
mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
factory)
: display_id_(display_id), factory_(std::move(factory)) {}
IsolatedGamepadDataFetcher::Factory::~Factory() {}
......@@ -291,7 +292,8 @@ void IsolatedGamepadDataFetcher::Factory::RemoveGamepad(
void IsolatedGamepadDataFetcher::Factory::AddGamepad(
device::mojom::XRDeviceId device_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr gamepad_factory) {
mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
gamepad_factory) {
if (!IsValidDeviceId(device_id))
return;
......
......@@ -18,19 +18,21 @@ class IsolatedGamepadDataFetcher : public GamepadDataFetcher {
class DEVICE_VR_EXPORT Factory : public GamepadDataFetcherFactory {
public:
Factory(device::mojom::XRDeviceId display_id,
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory);
mojo::PendingRemote<device::mojom::IsolatedXRGamepadProviderFactory>
factory);
~Factory() override;
std::unique_ptr<GamepadDataFetcher> CreateDataFetcher() override;
GamepadSource source() override;
static void AddGamepad(
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);
private:
device::mojom::XRDeviceId display_id_;
device::mojom::IsolatedXRGamepadProviderFactoryPtr factory_;
mojo::Remote<device::mojom::IsolatedXRGamepadProviderFactory> factory_;
};
IsolatedGamepadDataFetcher(
......
......@@ -96,7 +96,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(mojom::XRDeviceId id,
OculusDevice::OculusDevice()
: VRDeviceBase(mojom::XRDeviceId::OCULUS_DEVICE_ID),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this),
weak_ptr_factory_(this) {
render_loop_ = std::make_unique<OculusRenderLoop>();
......@@ -112,10 +111,9 @@ bool OculusDevice::IsApiAvailable() {
return result.IsOculusServiceRunning;
}
mojom::IsolatedXRGamepadProviderFactoryPtr OculusDevice::BindGamepadFactory() {
mojom::IsolatedXRGamepadProviderFactoryPtr ret;
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret));
return ret;
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
OculusDevice::BindGamepadFactory() {
return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
}
mojom::XRCompositorHostPtr OculusDevice::BindCompositorHost() {
......
......@@ -13,6 +13,7 @@
#include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/binding.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 "third_party/libovr/src/Include/OVR_CAPI.h"
......@@ -43,7 +44,8 @@ class DEVICE_VR_EXPORT OculusDevice
bool IsAvailable();
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory();
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost();
private:
......@@ -74,8 +76,8 @@ class DEVICE_VR_EXPORT OculusDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_;
mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
......@@ -124,7 +124,6 @@ mojom::VRDisplayInfoPtr CreateVRDisplayInfo(vr::IVRSystem* vr_system,
OpenVRDevice::OpenVRDevice()
: VRDeviceBase(device::mojom::XRDeviceId::OPENVR_DEVICE_ID),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this) {
render_loop_ = std::make_unique<OpenVRRenderLoop>();
......@@ -139,10 +138,9 @@ bool OpenVRDevice::IsApiAvailable() {
return vr::VR_IsRuntimeInstalled();
}
mojom::IsolatedXRGamepadProviderFactoryPtr OpenVRDevice::BindGamepadFactory() {
mojom::IsolatedXRGamepadProviderFactoryPtr ret;
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret));
return ret;
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
OpenVRDevice::BindGamepadFactory() {
return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
}
mojom::XRCompositorHostPtr OpenVRDevice::BindCompositorHost() {
......
......@@ -14,6 +14,7 @@
#include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace device {
......@@ -49,7 +50,8 @@ class DEVICE_VR_EXPORT OpenVRDevice
bool IsAvailable();
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory();
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost();
private:
......@@ -78,8 +80,8 @@ class DEVICE_VR_EXPORT OpenVRDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_;
mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
......@@ -86,7 +86,6 @@ bool OpenXrDevice::IsApiAvailable() {
OpenXrDevice::OpenXrDevice()
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this),
weak_ptr_factory_(this) {
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
......@@ -101,10 +100,9 @@ OpenXrDevice::~OpenXrDevice() {
}
}
mojom::IsolatedXRGamepadProviderFactoryPtr OpenXrDevice::BindGamepadFactory() {
mojom::IsolatedXRGamepadProviderFactoryPtr ret;
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret));
return ret;
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
OpenXrDevice::BindGamepadFactory() {
return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
}
mojom::XRCompositorHostPtr OpenXrDevice::BindCompositorHost() {
......
......@@ -11,6 +11,7 @@
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace device {
......@@ -34,7 +35,8 @@ class DEVICE_VR_EXPORT OpenXrDevice
mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) override;
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory();
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost();
private:
......@@ -62,8 +64,8 @@ class DEVICE_VR_EXPORT OpenXrDevice
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this};
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_;
mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
......
......@@ -198,7 +198,7 @@ interface IsolatedXRRuntimeProviderClient {
// Called when runtimes are initially enumerated, or when devices are later
// attached and become available.
OnDeviceAdded(XRRuntime runtime,
IsolatedXRGamepadProviderFactory gamepad_factory,
pending_remote<IsolatedXRGamepadProviderFactory> gamepad_factory,
XRCompositorHost compositor_host,
device.mojom.XRDeviceId device_id);
......
......@@ -63,7 +63,6 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
MixedRealityDevice::MixedRealityDevice()
: VRDeviceBase(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID),
gamepad_provider_factory_binding_(this),
compositor_host_binding_(this) {
SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
}
......@@ -72,11 +71,9 @@ MixedRealityDevice::~MixedRealityDevice() {
Shutdown();
}
mojom::IsolatedXRGamepadProviderFactoryPtr
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
MixedRealityDevice::BindGamepadFactory() {
mojom::IsolatedXRGamepadProviderFactoryPtr ret;
gamepad_provider_factory_binding_.Bind(mojo::MakeRequest(&ret));
return ret;
return gamepad_provider_factory_receiver_.BindNewPipeAndPassRemote();
}
mojom::XRCompositorHostPtr MixedRealityDevice::BindCompositorHost() {
......
......@@ -15,6 +15,7 @@
#include "device/vr/windows/compositor_base.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace device {
......@@ -28,7 +29,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice
MixedRealityDevice();
~MixedRealityDevice() override;
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory();
mojo::PendingRemote<mojom::IsolatedXRGamepadProviderFactory>
BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost();
private:
......@@ -59,8 +61,8 @@ class DEVICE_VR_EXPORT MixedRealityDevice
std::unique_ptr<XRCompositorCommon> render_loop_;
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_;
mojo::Receiver<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_receiver_{this};
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
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