Commit 1a72d2e8 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

WebXR depth: add web features and UseCounters

Change-Id: I0b0dc99e0e7ef9655d7308771822ffdece4057e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432671
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810891}
parent 3748ff56
......@@ -3010,6 +3010,10 @@ enum WebFeature {
kIdentifiabilityStudyReserved3680 = 3680,
kIdentifiabilityStudyReserved3681 = 3681,
kUndeferrableThirdPartySubresourceRequestWithCookie = 3682,
kXRDepthSensing = 3683,
kXRFrameGetDepthInformation = 3684,
kXRDepthInformationGetDepth = 3685,
kXRDepthInformationDataAttribute = 3686,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -7,6 +7,7 @@
Exposed=Window,
RuntimeEnabled=WebXRDepth
] interface XRDepthInformation {
[SameObject, MeasureAs=XRDepthInformationDataAttribute]
readonly attribute Uint16Array data;
readonly attribute unsigned long width;
......@@ -14,6 +15,6 @@
[SameObject] readonly attribute XRRigidTransform normTextureFromNormView;
[RaisesException]
[RaisesException, MeasureAs=XRDepthInformationGetDepth]
float getDepth(unsigned long column, unsigned long row);
};
......@@ -30,6 +30,6 @@
[RuntimeEnabled=WebXRLightEstimation, RaisesException]
XRLightEstimate? getLightEstimate(XRLightProbe lightProbe);
[RuntimeEnabled=WebXRDepth, RaisesException]
[RuntimeEnabled=WebXRDepth, RaisesException, MeasureAs=XRFrameGetDepthInformation]
XRDepthInformation getDepthInformation(XRView view);
};
......@@ -254,6 +254,18 @@ const char* GetConsoleMessage(device::mojom::RequestSessionError error) {
}
}
bool IsFeatureRequested(
device::mojom::XRSessionFeatureRequestStatus requestStatus) {
switch (requestStatus) {
case device::mojom::XRSessionFeatureRequestStatus::kOptionalAccepted:
case device::mojom::XRSessionFeatureRequestStatus::kRequired:
return true;
case device::mojom::XRSessionFeatureRequestStatus::kNotRequested:
case device::mojom::XRSessionFeatureRequestStatus::kOptionalRejected:
return false;
}
}
} // namespace
// Ensure that the inline session request is allowed, if not
......@@ -484,6 +496,8 @@ void XRSystem::PendingRequestSessionQuery::ReportRequestSessionResult(
GetFeatureRequestStatus(XRSessionFeature::REF_SPACE_UNBOUNDED, session);
auto feature_request_dom_overlay =
GetFeatureRequestStatus(XRSessionFeature::DOM_OVERLAY, session);
auto feature_request_depth_sensing =
GetFeatureRequestStatus(XRSessionFeature::DEPTH, session);
ukm::builders::XR_WebXR_SessionRequest(ukm_source_id_)
.SetMode(static_cast<int64_t>(mode_))
......@@ -499,12 +513,22 @@ void XRSystem::PendingRequestSessionQuery::ReportRequestSessionResult(
// If the session was successfully created and DOM overlay was requested,
// count this as a use of the DOM overlay feature.
if (session && status == SessionRequestStatus::kSuccess &&
feature_request_dom_overlay !=
device::mojom::XRSessionFeatureRequestStatus::kNotRequested) {
IsFeatureRequested(feature_request_dom_overlay)) {
DVLOG(2) << __func__ << ": DOM overlay was requested, logging a UseCounter";
UseCounter::Count(session->GetExecutionContext(),
WebFeature::kXRDOMOverlay);
}
// If the session was successfully created and depth-sensing was requested,
// count this as a use of depth sensing feature.
if (session && status == SessionRequestStatus::kSuccess &&
IsFeatureRequested(feature_request_depth_sensing)) {
DVLOG(2) << __func__
<< ": depth sensing was requested, logging a UseCounter";
UseCounter::Count(session->GetExecutionContext(),
WebFeature::kXRDepthSensing);
}
if (session && metrics_recorder) {
mojo::Remote<device::mojom::blink::XRSessionMetricsRecorder> recorder(
std::move(metrics_recorder));
......
......@@ -28814,6 +28814,7 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3047" label="PluginElementLoadedImage"/>
<int value="3048" label="PluginElementLoadedExternal"/>
<int value="3049" label="RenderSubtreeAttribute"/>
<int value="3050" label="ARIAAnnotations"/>
<int value="3051" label="IntersectionObserverV2"/>
<int value="3052" label="HeavyAdIntervention"/>
<int value="3053" label="UserTimingL3"/>
......@@ -29463,6 +29464,10 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3680" label="IdentifiabilityStudyReserved3680"/>
<int value="3681" label="IdentifiabilityStudyReserved3681"/>
<int value="3682" label="UndeferrableThirdPartySubresourceRequestWithCookie"/>
<int value="3683" label="XRDepthSensing"/>
<int value="3684" label="XRFrameGetDepthInformation"/>
<int value="3685" label="XRDepthInformationGetDepth"/>
<int value="3686" label="XRDepthInformationDataAttribute"/>
</enum>
<enum name="FeaturePolicyAllowlistType">
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