Commit 418c271b authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate references of device::mojom::XREnvironmentIntegrationProvider

Convert the remaining bits in both the implementation and clients from the
browser and renderer processes for the XREnvironmentIntegrationProvider
interface, and adapt unit tests.

Bug: 955171, 978694
Change-Id: I261bdae8d49490a58a098545ef692fbf84b6d256
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1836416
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarChristopher Grant <cjgrant@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706421}
parent 1e63f8cb
......@@ -18,6 +18,7 @@
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/test/fake_vr_device.h"
#include "device/vr/test/fake_vr_service_client.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -136,14 +137,15 @@ class ArCoreDeviceTest : public testing::Test {
frame_provider.Bind(std::move(session_->data_provider));
frame_provider->GetEnvironmentIntegrationProvider(
mojo::MakeRequest(&environment_provider));
environment_provider.BindNewEndpointAndPassReceiver());
std::move(quit_closure).Run();
}
StubMailboxToSurfaceBridge* bridge;
StubArCoreSessionUtils* session_utils;
mojo::Remote<mojom::XRFrameDataProvider> frame_provider;
mojom::XREnvironmentIntegrationProviderAssociatedPtr environment_provider;
mojo::AssociatedRemote<mojom::XREnvironmentIntegrationProvider>
environment_provider;
std::unique_ptr<base::RunLoop> run_loop;
base::OnceClosure quit_closure;
......
......@@ -100,8 +100,7 @@ struct ArCoreHitTestRequest {
ArCoreGl::ArCoreGl(std::unique_ptr<ArImageTransport> ar_image_transport)
: gl_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
ar_image_transport_(std::move(ar_image_transport)),
webxr_(std::make_unique<vr::WebXrPresentationState>()),
environment_binding_(this) {
webxr_(std::make_unique<vr::WebXrPresentationState>()) {
DVLOG(1) << __func__;
}
......@@ -618,15 +617,16 @@ void ArCoreGl::UpdateLayerBounds(int16_t frame_index,
}
void ArCoreGl::GetEnvironmentIntegrationProvider(
device::mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_request) {
mojo::PendingAssociatedReceiver<
device::mojom::XREnvironmentIntegrationProvider> environment_provider) {
DVLOG(3) << __func__;
DCHECK(IsOnGlThread());
DCHECK(is_initialized_);
environment_binding_.Bind(std::move(environment_request));
environment_binding_.set_connection_error_handler(base::BindOnce(
environment_receiver_.reset();
environment_receiver_.Bind(std::move(environment_provider));
environment_receiver_.set_disconnect_handler(base::BindOnce(
&ArCoreGl::OnBindingDisconnect, weak_ptr_factory_.GetWeakPtr()));
}
......@@ -919,7 +919,7 @@ void ArCoreGl::OnBindingDisconnect() {
void ArCoreGl::CloseBindingsIfOpen() {
DVLOG(3) << __func__;
environment_binding_.Close();
environment_receiver_.reset();
frame_data_receiver_.reset();
session_controller_receiver_.reset();
presentation_receiver_.reset();
......
......@@ -18,7 +18,8 @@
#include "device/vr/public/mojom/isolated_xr_service.mojom.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/util/fps_meter.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
......@@ -87,7 +88,7 @@ class ArCoreGl : public mojom::XRFrameDataProvider,
GetFrameDataCallback callback) override;
void GetEnvironmentIntegrationProvider(
mojom::XREnvironmentIntegrationProviderAssociatedRequest
mojo::PendingAssociatedReceiver<mojom::XREnvironmentIntegrationProvider>
environment_provider) override;
void SetInputSourceButtonListener(
mojo::PendingAssociatedRemote<device::mojom::XRInputSourceButtonListener>)
......@@ -226,8 +227,8 @@ class ArCoreGl : public mojom::XRFrameDataProvider,
mojo::Receiver<mojom::XRFrameDataProvider> frame_data_receiver_{this};
mojo::Receiver<mojom::XRSessionController> session_controller_receiver_{this};
mojo::AssociatedBinding<mojom::XREnvironmentIntegrationProvider>
environment_binding_;
mojo::AssociatedReceiver<mojom::XREnvironmentIntegrationProvider>
environment_receiver_{this};
void OnBindingDisconnect();
void CloseBindingsIfOpen();
......
......@@ -1317,8 +1317,8 @@ void GvrSchedulerDelegate::ProcessWebVrFrameFromGMB(
}
void GvrSchedulerDelegate::GetEnvironmentIntegrationProvider(
device::mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_provider) {
mojo::PendingAssociatedReceiver<
device::mojom::XREnvironmentIntegrationProvider> environment_provider) {
// Environment integration is not supported. This call should not
// be made on this device.
mojo::ReportBadMessage("Environment integration is not supported.");
......
......@@ -20,6 +20,7 @@
#include "chrome/browser/vr/base_scheduler_delegate.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/util/sliding_average.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -140,8 +141,9 @@ class GvrSchedulerDelegate : public BaseSchedulerDelegate,
device::mojom::XRFrameDataProvider::GetFrameDataCallback
callback) override;
void GetEnvironmentIntegrationProvider(
device::mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_provider) override;
mojo::PendingAssociatedReceiver<
device::mojom::XREnvironmentIntegrationProvider> environment_provider)
override;
void SetInputSourceButtonListener(
mojo::PendingAssociatedRemote<device::mojom::XRInputSourceButtonListener>)
override;
......
......@@ -44,8 +44,8 @@ void VROrientationSession::GetFrameData(
}
void VROrientationSession::GetEnvironmentIntegrationProvider(
mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_request) {
mojo::PendingAssociatedReceiver<mojom::XREnvironmentIntegrationProvider>
environment_provider) {
// Environment integration is not supported. This call should not
// be made on this device.
mojo::ReportBadMessage("Environment integration is not supported.");
......
......@@ -13,6 +13,7 @@
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device.h"
#include "device/vr/vr_export.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
......@@ -36,7 +37,7 @@ class DEVICE_VR_EXPORT VROrientationSession
~VROrientationSession() override;
void GetEnvironmentIntegrationProvider(
mojom::XREnvironmentIntegrationProviderAssociatedRequest
mojo::PendingAssociatedReceiver<mojom::XREnvironmentIntegrationProvider>
environment_provider) override;
void SetInputSourceButtonListener(
mojo::PendingAssociatedRemote<device::mojom::XRInputSourceButtonListener>)
......
......@@ -602,7 +602,8 @@ interface XRFrameDataProvider {
// for some reason, such as device disconnection.
GetFrameData(XRFrameDataRequestOptions? options) => (XRFrameData? frame_data);
GetEnvironmentIntegrationProvider(
associated XREnvironmentIntegrationProvider& environment_provider);
pending_associated_receiver<XREnvironmentIntegrationProvider>
environment_provider);
SetInputSourceButtonListener(
pending_associated_remote<XRInputSourceButtonListener>? event_listener);
};
......
......@@ -412,8 +412,8 @@ void XRCompositorCommon::GetControllerDataAndSendFrameData(
}
void XRCompositorCommon::GetEnvironmentIntegrationProvider(
device::mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_provider) {
mojo::PendingAssociatedReceiver<
device::mojom::XREnvironmentIntegrationProvider> environment_provider) {
// Environment integration is not supported. This call should not
// be made on this device.
mojo::ReportBadMessage("Environment integration is not supported.");
......
......@@ -14,6 +14,7 @@
#include "device/vr/util/sliding_average.h"
#include "device/vr/vr_device.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
......@@ -75,8 +76,9 @@ class XRCompositorCommon : public base::Thread,
mojom::XRFrameDataPtr frame_data);
void GetEnvironmentIntegrationProvider(
device::mojom::XREnvironmentIntegrationProviderAssociatedRequest
environment_provider) final;
mojo::PendingAssociatedReceiver<
device::mojom::XREnvironmentIntegrationProvider> environment_provider)
final;
void RequestGamepadProvider(
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> receiver);
......
......@@ -29,6 +29,7 @@
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
namespace {
......@@ -466,8 +467,9 @@ XRFrameProvider* XR::frameProvider() {
return frame_provider_;
}
const device::mojom::blink::XREnvironmentIntegrationProviderAssociatedPtr&
XR::xrEnvironmentProviderPtr() {
const mojo::AssociatedRemote<
device::mojom::blink::XREnvironmentIntegrationProvider>&
XR::xrEnvironmentProviderRemote() {
return environment_provider_;
}
......@@ -934,10 +936,11 @@ void XR::OnRequestSessionReturned(
// https://docs.google.com/spreadsheets/d/1b-dus1Ug3A8y0lX0blkmOjJILisUASdj8x9YN_XMwYc/view
frameProvider()
->GetImmersiveDataProvider()
->GetEnvironmentIntegrationProvider(mojo::MakeRequest(
&environment_provider_, GetExecutionContext()->GetTaskRunner(
TaskType::kMiscPlatformAPI)));
environment_provider_.set_connection_error_handler(WTF::Bind(
->GetEnvironmentIntegrationProvider(
environment_provider_.BindNewEndpointAndPassReceiver(
GetExecutionContext()->GetTaskRunner(
TaskType::kMiscPlatformAPI)));
environment_provider_.set_disconnect_handler(WTF::Bind(
&XR::OnEnvironmentProviderDisconnect, WrapWeakPersistent(this)));
session->OnEnvironmentProviderCreated();
......
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_XR_XR_H_
#include "device/vr/public/mojom/vr_service.mojom-blink.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -59,8 +60,9 @@ class XR final : public EventTargetWithInlineData,
XRFrameProvider* frameProvider();
const device::mojom::blink::XREnvironmentIntegrationProviderAssociatedPtr&
xrEnvironmentProviderPtr();
const mojo::AssociatedRemote<
device::mojom::blink::XREnvironmentIntegrationProvider>&
xrEnvironmentProviderRemote();
// VRServiceClient overrides.
void OnDeviceChanged() override;
......@@ -297,7 +299,7 @@ class XR final : public EventTargetWithInlineData,
Member<XRFrameProvider> frame_provider_;
HeapHashSet<WeakMember<XRSession>> sessions_;
mojo::Remote<device::mojom::blink::VRService> service_;
device::mojom::blink::XREnvironmentIntegrationProviderAssociatedPtr
mojo::AssociatedRemote<device::mojom::blink::XREnvironmentIntegrationProvider>
environment_provider_;
mojo::Receiver<device::mojom::blink::VRServiceClient> receiver_{this};
......
......@@ -72,7 +72,7 @@ double XRAnchor::lastChangedTime(bool& is_null) const {
}
void XRAnchor::detach() {
session_->xr()->xrEnvironmentProviderPtr()->DetachAnchor(id_);
session_->xr()->xrEnvironmentProviderRemote()->DetachAnchor(id_);
}
void XRAnchor::Trace(blink::Visitor* visitor) {
......
......@@ -412,7 +412,7 @@ ScriptPromise XRSession::CreateAnchor(ScriptState* script_state,
}
// Reject the promise if device doesn't support the anchors API.
if (!xr_->xrEnvironmentProviderPtr()) {
if (!xr_->xrEnvironmentProviderRemote()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
kAnchorsNotSupported);
return ScriptPromise();
......@@ -473,12 +473,12 @@ ScriptPromise XRSession::CreateAnchor(ScriptState* script_state,
<< pose_ptr->position->y << ", " << pose_ptr->position->z << "]";
if (plane) {
xr_->xrEnvironmentProviderPtr()->CreatePlaneAnchor(
xr_->xrEnvironmentProviderRemote()->CreatePlaneAnchor(
std::move(pose_ptr), plane->id(),
WTF::Bind(&XRSession::OnCreateAnchorResult, WrapPersistent(this),
WrapPersistent(resolver)));
} else {
xr_->xrEnvironmentProviderPtr()->CreateAnchor(
xr_->xrEnvironmentProviderRemote()->CreateAnchor(
std::move(pose_ptr),
WTF::Bind(&XRSession::OnCreateAnchorResult, WrapPersistent(this),
WrapPersistent(resolver)));
......@@ -541,7 +541,7 @@ ScriptPromise XRSession::requestHitTest(ScriptState* script_state,
}
// Reject the promise if device doesn't support the hit-test API.
if (!xr_->xrEnvironmentProviderPtr()) {
if (!xr_->xrEnvironmentProviderRemote()) {
exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
kHitTestNotSupported);
return ScriptPromise();
......@@ -558,7 +558,7 @@ ScriptPromise XRSession::requestHitTest(ScriptState* script_state,
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
xr_->xrEnvironmentProviderPtr()->RequestHitTest(
xr_->xrEnvironmentProviderRemote()->RequestHitTest(
std::move(ray_mojo),
WTF::Bind(&XRSession::OnHitTestResults, WrapPersistent(this),
WrapPersistent(resolver)));
......@@ -622,7 +622,7 @@ ScriptPromise XRSession::requestHitTestSource(
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
xr_->xrEnvironmentProviderPtr()->SubscribeToHitTest(
xr_->xrEnvironmentProviderRemote()->SubscribeToHitTest(
maybe_native_origin->ToMojo(), std::move(ray_mojo),
WTF::Bind(&XRSession::OnSubscribeToHitTestResult, WrapPersistent(this),
WrapPersistent(resolver), WrapPersistent(options)));
......@@ -698,7 +698,7 @@ void XRSession::EnsureEnvironmentErrorHandler() {
// Install error handler on environment provider to ensure that we get
// notified so that we can clean up all relevant pending promises.
if (!environment_error_handler_subscribed_ &&
xr_->xrEnvironmentProviderPtr()) {
xr_->xrEnvironmentProviderRemote()) {
environment_error_handler_subscribed_ = true;
xr_->AddEnvironmentProviderErrorHandler(WTF::Bind(
&XRSession::OnEnvironmentProviderError, WrapWeakPersistent(this)));
......
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