chromium/content/browser/xr/webxr_internals/mojom/webxr_internals.mojom

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module webxr.mojom;

import "device/vr/public/mojom/xr_device.mojom";
import "device/vr/public/mojom/xr_session.mojom";
import "mojo/public/mojom/base/time.mojom";

// Human readable information about the device
struct DeviceInfo {
    string operating_system_name;
    string operating_system_version;
    string gpu_gl_vendor;
    string gpu_gl_renderer;
};

// Human readable information about the session requested record.
struct SessionRequestedRecord {
    device.mojom.XRSessionOptions options;
    mojo_base.mojom.Time requested_time;
};

// Human readable information about the session rejected record.
struct SessionRejectedRecord {
    // ID of this request, used for tracing.
    uint64 trace_id;
    device.mojom.RequestSessionError failure_reason;
    mojo_base.mojom.Time rejected_time;
    string failure_reason_description;
    array<device.mojom.XRSessionFeature> rejected_features;
};

// Human readable information about the session started record.
struct SessionStartedRecord {
    // ID of this request, used for tracing.
    uint64 trace_id;
    device.mojom.XRDeviceId device_id;
    mojo_base.mojom.Time started_time;
};

// Human readable information about the session stopped record.
struct SessionStoppedRecord {
    // ID of this request, used for tracing.
    uint64 trace_id;
    mojo_base.mojom.Time stopped_time;
};

// Human readable information about the runtime info.
// Note: We don't use device.mojom.XRDeviceData here due to conflicts with
// building the luid for WebUI. Instead, we create RuntimeInfo without
// specifying the luid.
struct RuntimeInfo {
    device.mojom.XRDeviceId device_id;
    array<device.mojom.XRSessionFeature> supported_features;
    bool is_ar_blend_mode_supported;
};

// Interface for controlling WebXR Internals.
// Handles requests from "chrome://webxr-internals"
// This is expected to be hosted in the browser process and is used from the
// WebUI renderer.
interface WebXrInternalsHandler {
    // Returns information about the operating system name,
    // operating system version, GPU driver and GPU vendor ID.
    GetDeviceInfo() => (DeviceInfo device_info);

    // Returns information about active runtimes, including:
    // Device ID, Supported Features and the runtime supports AR or not.
    GetActiveRuntimes() => (array<RuntimeInfo> active_runtimes);

    // Subscribes to events with a pending remote XrInternalsSessionListener
    SubscribeToEvents(pending_remote<XRInternalsSessionListener> listener);
};

// Used by webxr internals WebUI to query browser process about session
// events.
interface XRInternalsSessionListener {
    // Begin listening for updates to log session requested record.
    LogXrSessionRequested(SessionRequestedRecord session_requested_record);

    // Begin listening for updates to log session rejected record.
    LogXrSessionRejected(SessionRejectedRecord session_rejected_record);

    // Begin listening for updates to log session started record.
    LogXrSessionStarted(SessionStartedRecord session_started_record);

    // Begin listening for updates to log session stopped record.
    LogXrSessionStopped(SessionStoppedRecord session_stopped_record);

    // Begin listening for updates to log runtime added record.
    // This method does not send historical data.
    LogXrRuntimeAdded(RuntimeInfo runtime_added_record);

    // Begin listening for updates to log runtime removed
    // for the specified XR device.
    // This method does not send historical data.
    LogXrRuntimeRemoved(device.mojom.XRDeviceId device_id);

    // Begin listening for incoming frames for diagnostics calculation.
    // This method does not send historical data.
    LogFrameData(device.mojom.XrFrameStatistics xrframe_statistics);

    // Begin listening for incoming console messages for diagnostics.
    // This method does not send historical data.
    LogConsoleMessages(device.mojom.XrLogMessage xrlogging_statistics);
};