Commit dc3a8ecc authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Don't store ukm::SourceId on XRSystem

The XRSystem is currently provided its document's ukm::SourceId in its
constructor, which is then stored in a member variable. Instead, we can
simply get it from the document/execution context as needed.

Follows from comments in crrev.com/c/2267639.

Bug: 1100349
Change-Id: Ie89c7fa55ee27aa07cc799666c83443122d721fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451384Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814353}
parent 44093a32
...@@ -65,10 +65,8 @@ XRSystem* NavigatorXR::xr() { ...@@ -65,10 +65,8 @@ XRSystem* NavigatorXR::xr() {
did_log_navigator_xr_ = true; did_log_navigator_xr_ = true;
} }
if (!xr_) { if (!xr_)
xr_ = MakeGarbageCollected<XRSystem>(*document->GetFrame(), xr_ = MakeGarbageCollected<XRSystem>(*document->GetFrame());
document->UkmSourceID());
}
return xr_; return xr_;
} }
......
...@@ -732,7 +732,7 @@ void XRSession::cancelAnimationFrame(int id) { ...@@ -732,7 +732,7 @@ void XRSession::cancelAnimationFrame(int id) {
XRInputSourceArray* XRSession::inputSources(ScriptState* script_state) const { XRInputSourceArray* XRSession::inputSources(ScriptState* script_state) const {
if (!did_log_getInputSources_ && script_state->ContextIsValid()) { if (!did_log_getInputSources_ && script_state->ContextIsValid()) {
ukm::builders::XR_WebXR(xr_->GetSourceId()) ukm::builders::XR_WebXR(GetExecutionContext()->UkmSourceID())
.SetDidGetXRInputSources(1) .SetDidGetXRInputSources(1)
.Record(LocalDOMWindow::From(script_state)->UkmRecorder()); .Record(LocalDOMWindow::From(script_state)->UkmRecorder());
did_log_getInputSources_ = true; did_log_getInputSources_ = true;
...@@ -1726,7 +1726,7 @@ void XRSession::LogGetPose() const { ...@@ -1726,7 +1726,7 @@ void XRSession::LogGetPose() const {
if (!did_log_getViewerPose_ && GetExecutionContext()) { if (!did_log_getViewerPose_ && GetExecutionContext()) {
did_log_getViewerPose_ = true; did_log_getViewerPose_ = true;
ukm::builders::XR_WebXR(xr_->GetSourceId()) ukm::builders::XR_WebXR(GetExecutionContext()->UkmSourceID())
.SetDidRequestPose(1) .SetDidRequestPose(1)
.Record(GetExecutionContext()->UkmRecorder()); .Record(GetExecutionContext()->UkmRecorder());
} }
......
...@@ -761,10 +761,9 @@ device::mojom::blink::XRSessionOptionsPtr XRSystem::XRSessionOptionsFromQuery( ...@@ -761,10 +761,9 @@ device::mojom::blink::XRSessionOptionsPtr XRSystem::XRSessionOptionsFromQuery(
return session_options; return session_options;
} }
XRSystem::XRSystem(LocalFrame& frame, int64_t ukm_source_id) XRSystem::XRSystem(LocalFrame& frame)
: ExecutionContextLifecycleObserver(frame.DomWindow()), : ExecutionContextLifecycleObserver(frame.DomWindow()),
FocusChangedObserver(frame.GetPage()), FocusChangedObserver(frame.GetPage()),
ukm_source_id_(ukm_source_id),
service_(frame.DomWindow()), service_(frame.DomWindow()),
environment_provider_(frame.DomWindow()), environment_provider_(frame.DomWindow()),
receiver_(this, frame.DomWindow()), receiver_(this, frame.DomWindow()),
...@@ -971,7 +970,7 @@ void XRSystem::RequestImmersiveSession(LocalFrame* frame, ...@@ -971,7 +970,7 @@ void XRSystem::RequestImmersiveSession(LocalFrame* frame,
DVLOG(2) << __func__; DVLOG(2) << __func__;
// Log an immersive session request if we haven't already // Log an immersive session request if we haven't already
if (!did_log_request_immersive_session_) { if (!did_log_request_immersive_session_) {
ukm::builders::XR_WebXR(GetSourceId()) ukm::builders::XR_WebXR(doc->UkmSourceID())
.SetDidRequestPresentation(1) .SetDidRequestPresentation(1)
.Record(doc->UkmRecorder()); .Record(doc->UkmRecorder());
did_log_request_immersive_session_ = true; did_log_request_immersive_session_ = true;
...@@ -1206,7 +1205,7 @@ ScriptPromise XRSystem::requestSession(ScriptState* script_state, ...@@ -1206,7 +1205,7 @@ ScriptPromise XRSystem::requestSession(ScriptState* script_state,
// We haven't created the query yet, so we can't use it to implicitly log // We haven't created the query yet, so we can't use it to implicitly log
// our metrics for us, so explicitly log it here, as the query requires the // our metrics for us, so explicitly log it here, as the query requires the
// features to be parsed before it can be built. // features to be parsed before it can be built.
ukm::builders::XR_WebXR_SessionRequest(GetSourceId()) ukm::builders::XR_WebXR_SessionRequest(doc->UkmSourceID())
.SetMode(static_cast<int64_t>(session_mode)) .SetMode(static_cast<int64_t>(session_mode))
.SetStatus(static_cast<int64_t>(SessionRequestStatus::kOtherError)) .SetStatus(static_cast<int64_t>(SessionRequestStatus::kOtherError))
.Record(doc->UkmRecorder()); .Record(doc->UkmRecorder());
...@@ -1260,8 +1259,8 @@ ScriptPromise XRSystem::requestSession(ScriptState* script_state, ...@@ -1260,8 +1259,8 @@ ScriptPromise XRSystem::requestSession(ScriptState* script_state,
PendingRequestSessionQuery* query = PendingRequestSessionQuery* query =
MakeGarbageCollected<PendingRequestSessionQuery>( MakeGarbageCollected<PendingRequestSessionQuery>(
GetSourceId(), resolver, session_mode, std::move(required_features), doc->UkmSourceID(), resolver, session_mode,
std::move(optional_features)); std::move(required_features), std::move(optional_features));
if (query->HasFeature(device::mojom::XRSessionFeature::DOM_OVERLAY)) { if (query->HasFeature(device::mojom::XRSessionFeature::DOM_OVERLAY)) {
// Prerequisites were checked by IsFeatureValidForMode and IDL. // Prerequisites were checked by IsFeatureValidForMode and IDL.
...@@ -1491,7 +1490,7 @@ void XRSystem::OnRequestSessionReturned( ...@@ -1491,7 +1490,7 @@ void XRSystem::OnRequestSessionReturned(
void XRSystem::ReportImmersiveSupported(bool supported) { void XRSystem::ReportImmersiveSupported(bool supported) {
Document* doc = GetFrame() ? GetFrame()->GetDocument() : nullptr; Document* doc = GetFrame() ? GetFrame()->GetDocument() : nullptr;
if (doc && !did_log_supports_immersive_ && supported) { if (doc && !did_log_supports_immersive_ && supported) {
ukm::builders::XR_WebXR ukm_builder(ukm_source_id_); ukm::builders::XR_WebXR ukm_builder(doc->UkmSourceID());
ukm_builder.SetReturnedPresentationCapableDevice(1); ukm_builder.SetReturnedPresentationCapableDevice(1);
ukm_builder.Record(doc->UkmRecorder()); ukm_builder.Record(doc->UkmRecorder());
did_log_supports_immersive_ = true; did_log_supports_immersive_ = true;
......
...@@ -68,7 +68,7 @@ class XRSystem final : public EventTargetWithInlineData, ...@@ -68,7 +68,7 @@ class XRSystem final : public EventTargetWithInlineData,
public: public:
// TODO(crbug.com/976796): Fix lint errors. // TODO(crbug.com/976796): Fix lint errors.
XRSystem(LocalFrame& frame, int64_t ukm_source_id); explicit XRSystem(LocalFrame& frame);
DEFINE_ATTRIBUTE_EVENT_LISTENER(devicechange, kDevicechange) DEFINE_ATTRIBUTE_EVENT_LISTENER(devicechange, kDevicechange)
...@@ -103,8 +103,6 @@ class XRSystem final : public EventTargetWithInlineData, ...@@ -103,8 +103,6 @@ class XRSystem final : public EventTargetWithInlineData,
void FocusedFrameChanged() override; void FocusedFrameChanged() override;
bool IsFrameFocused(); bool IsFrameFocused();
int64_t GetSourceId() const { return ukm_source_id_; }
using EnvironmentProviderErrorCallback = base::OnceCallback<void()>; using EnvironmentProviderErrorCallback = base::OnceCallback<void()>;
// Registers a callback that'll be invoked when mojo invokes a disconnect // Registers a callback that'll be invoked when mojo invokes a disconnect
// handler on the underlying XREnvironmentIntegrationProvider remote. // handler on the underlying XREnvironmentIntegrationProvider remote.
...@@ -419,8 +417,6 @@ class XRSystem final : public EventTargetWithInlineData, ...@@ -419,8 +417,6 @@ class XRSystem final : public EventTargetWithInlineData,
// Indicates whether we've already logged a request for an immersive session. // Indicates whether we've already logged a request for an immersive session.
bool did_log_request_immersive_session_ = false; bool did_log_request_immersive_session_ = false;
const int64_t ukm_source_id_;
// The XR object owns outstanding pending session queries, these live until // The XR object owns outstanding pending session queries, these live until
// the underlying promise is either resolved or rejected. // the underlying promise is either resolved or rejected.
HeapHashSet<Member<PendingSupportsSessionQuery>> outstanding_support_queries_; HeapHashSet<Member<PendingSupportsSessionQuery>> outstanding_support_queries_;
......
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