Commit ff8b40b7 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

Add class to keep track of outstanding `XR:requestSession()` calls

This change adds PendingRequestSessionQuery class to encapsulate
outstanding `requestSession()` calls. It will automatically record
UKM entries when the request is resolved or rejected.

Rename PendingSessionQuery to PendingSupportsSessionQuery.

Bug: 968622
Change-Id: Id33524182eb555802d1ef02fc78741b4276ec290
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648788Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667364}
parent 9982cd6a
...@@ -86,13 +86,75 @@ bool AreArRuntimeFeaturesEnabled(const FeatureContext* context) { ...@@ -86,13 +86,75 @@ bool AreArRuntimeFeaturesEnabled(const FeatureContext* context) {
} // namespace } // namespace
XR::PendingSessionQuery::PendingSessionQuery( XR::PendingSupportsSessionQuery::PendingSupportsSessionQuery(
ScriptPromiseResolver* resolver, ScriptPromiseResolver* resolver,
XRSession::SessionMode session_mode) XRSession::SessionMode session_mode)
: resolver(resolver), mode(session_mode) {} : resolver_(resolver), mode_(session_mode) {}
void XR::PendingSessionQuery::Trace(blink::Visitor* visitor) { void XR::PendingSupportsSessionQuery::Trace(blink::Visitor* visitor) {
visitor->Trace(resolver); visitor->Trace(resolver_);
}
void XR::PendingSupportsSessionQuery::Resolve() {
resolver_->Resolve();
}
void XR::PendingSupportsSessionQuery::Reject(DOMException* exception) {
resolver_->Reject(exception);
}
void XR::PendingSupportsSessionQuery::Reject(v8::Local<v8::Value> value) {
resolver_->Reject(value);
}
XRSession::SessionMode XR::PendingSupportsSessionQuery::mode() const {
return mode_;
}
XR::PendingRequestSessionQuery::PendingRequestSessionQuery(
int64_t ukm_source_id,
ScriptPromiseResolver* resolver,
XRSession::SessionMode session_mode)
: resolver_(resolver), mode_(session_mode), ukm_source_id_(ukm_source_id) {}
void XR::PendingRequestSessionQuery::Resolve(XRSession* session) {
ReportRequestSessionResult(SessionRequestStatus::kSuccess);
resolver_->Resolve(session);
}
void XR::PendingRequestSessionQuery::Reject(DOMException* exception) {
ReportRequestSessionResult(SessionRequestStatus::kOtherError);
resolver_->Reject(exception);
}
void XR::PendingRequestSessionQuery::Reject(v8::Local<v8::Value> value) {
ReportRequestSessionResult(SessionRequestStatus::kOtherError);
resolver_->Reject(value);
}
XRSession::SessionMode XR::PendingRequestSessionQuery::mode() const {
return mode_;
}
ScriptState* XR::PendingRequestSessionQuery::GetScriptState() const {
return resolver_->GetScriptState();
}
void XR::PendingRequestSessionQuery::Trace(blink::Visitor* visitor) {
visitor->Trace(resolver_);
}
void XR::PendingRequestSessionQuery::ReportRequestSessionResult(
SessionRequestStatus status) {
Document* doc =
resolver_->GetFrame() ? resolver_->GetFrame()->GetDocument() : nullptr;
if (!doc)
return;
ukm::builders::XR_WebXR_SessionRequest(ukm_source_id_)
.SetMode(static_cast<int64_t>(mode_))
.SetStatus(static_cast<int64_t>(status))
.Record(doc->UkmRecorder());
} }
XR::XR(LocalFrame& frame, int64_t ukm_source_id) XR::XR(LocalFrame& frame, int64_t ukm_source_id)
...@@ -180,35 +242,34 @@ ScriptPromise XR::supportsSession(ScriptState* script_state, ...@@ -180,35 +242,34 @@ ScriptPromise XR::supportsSession(ScriptState* script_state,
Document* doc = frame->GetDocument(); Document* doc = frame->GetDocument();
XRSession::SessionMode session_mode = stringToSessionMode(mode); XRSession::SessionMode session_mode = stringToSessionMode(mode);
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
PendingSupportsSessionQuery* query =
MakeGarbageCollected<PendingSupportsSessionQuery>(resolver, session_mode);
if (session_mode == XRSession::kModeImmersiveAR && if (session_mode == XRSession::kModeImmersiveAR &&
!AreArRuntimeFeaturesEnabled(doc)) { !AreArRuntimeFeaturesEnabled(doc)) {
return ScriptPromise::Reject( query->Reject(V8ThrowException::CreateTypeError(
script_state, V8ThrowException::CreateTypeError(
script_state->GetIsolate(), script_state->GetIsolate(),
String::Format(kImmersiveArModeNotValid, __func__))); String::Format(kImmersiveArModeNotValid, __func__)));
return promise;
} }
if (!doc->IsFeatureEnabled(mojom::FeaturePolicyFeature::kWebVr, if (!doc->IsFeatureEnabled(mojom::FeaturePolicyFeature::kWebVr,
ReportOptions::kReportOnFailure)) { ReportOptions::kReportOnFailure)) {
// Only allow the call to be made if the appropriate feature policy is in // Only allow the call to be made if the appropriate feature policy is in
// place. // place.
return ScriptPromise::RejectWithDOMException( query->Reject(MakeGarbageCollected<DOMException>(
script_state, DOMExceptionCode::kSecurityError, kFeaturePolicyBlocked));
MakeGarbageCollected<DOMException>(DOMExceptionCode::kSecurityError, return promise;
kFeaturePolicyBlocked));
} }
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
if (session_mode == XRSession::kModeInline) { if (session_mode == XRSession::kModeInline) {
// `inline` sessions are always supported if not blocked by feature policy. // `inline` sessions are always supported if not blocked by feature policy.
resolver->Resolve(); query->Resolve();
} else { } else {
// For all other modes we need to check with the service. // For all other modes we need to check with the service.
PendingSessionQuery* query =
MakeGarbageCollected<PendingSessionQuery>(resolver, session_mode);
if (!device_) { if (!device_) {
pending_mode_queries_.push_back(query); pending_mode_queries_.push_back(query);
...@@ -222,17 +283,17 @@ ScriptPromise XR::supportsSession(ScriptState* script_state, ...@@ -222,17 +283,17 @@ ScriptPromise XR::supportsSession(ScriptState* script_state,
return promise; return promise;
} }
void XR::DispatchSupportsSession(PendingSessionQuery* query) { void XR::DispatchSupportsSession(PendingSupportsSessionQuery* query) {
if (!device_) { if (!device_) {
// If we don't have a device by the time we reach this call it indicates // If we don't have a device by the time we reach this call it indicates
// that there's no WebXR hardware. Reject as not supported. // that there's no WebXR hardware. Reject as not supported.
query->resolver->Reject(MakeGarbageCollected<DOMException>( query->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, kSessionNotSupported)); DOMExceptionCode::kNotSupportedError, kSessionNotSupported));
return; return;
} }
device::mojom::blink::XRSessionOptionsPtr session_options = device::mojom::blink::XRSessionOptionsPtr session_options =
convertModeToMojo(query->mode); convertModeToMojo(query->mode());
outstanding_support_queries_.insert(query); outstanding_support_queries_.insert(query);
device_->SupportsSession( device_->SupportsSession(
...@@ -262,13 +323,20 @@ ScriptPromise XR::requestSession(ScriptState* script_state, ...@@ -262,13 +323,20 @@ ScriptPromise XR::requestSession(ScriptState* script_state,
Document* doc = frame->GetDocument(); Document* doc = frame->GetDocument();
XRSession::SessionMode session_mode = stringToSessionMode(mode); XRSession::SessionMode session_mode = stringToSessionMode(mode);
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
PendingRequestSessionQuery* query =
MakeGarbageCollected<PendingRequestSessionQuery>(GetSourceId(), resolver,
session_mode);
if (session_mode == XRSession::kModeImmersiveAR && if (session_mode == XRSession::kModeImmersiveAR &&
!AreArRuntimeFeaturesEnabled(doc)) { !AreArRuntimeFeaturesEnabled(doc)) {
ReportRequestSessionResult(session_mode, SessionRequestStatus::kOtherError); query->Reject(V8ThrowException::CreateTypeError(
return ScriptPromise::Reject(
script_state, V8ThrowException::CreateTypeError(
script_state->GetIsolate(), script_state->GetIsolate(),
String::Format(kImmersiveArModeNotValid, __func__))); String::Format(kImmersiveArModeNotValid, __func__)));
return promise;
} }
bool is_immersive = session_mode == XRSession::kModeImmersiveVR || bool is_immersive = session_mode == XRSession::kModeImmersiveVR ||
...@@ -285,30 +353,24 @@ ScriptPromise XR::requestSession(ScriptState* script_state, ...@@ -285,30 +353,24 @@ ScriptPromise XR::requestSession(ScriptState* script_state,
ReportOptions::kReportOnFailure)) { ReportOptions::kReportOnFailure)) {
// Only allow the call to be made if the appropriate feature policy is in // Only allow the call to be made if the appropriate feature policy is in
// place. // place.
ReportRequestSessionResult(session_mode, SessionRequestStatus::kOtherError); query->Reject(MakeGarbageCollected<DOMException>(
return ScriptPromise::RejectWithDOMException( DOMExceptionCode::kSecurityError, kFeaturePolicyBlocked));
script_state, return promise;
MakeGarbageCollected<DOMException>(DOMExceptionCode::kSecurityError,
kFeaturePolicyBlocked));
} }
// Only one immersive session can be active at a time. // Only one immersive session can be active at a time.
if (is_immersive && frameProvider()->immersive_session()) { if (is_immersive && frameProvider()->immersive_session()) {
ReportRequestSessionResult(session_mode, SessionRequestStatus::kOtherError); query->Reject(MakeGarbageCollected<DOMException>(
return ScriptPromise::RejectWithDOMException( DOMExceptionCode::kInvalidStateError, kActiveImmersiveSession));
script_state, return promise;
MakeGarbageCollected<DOMException>(DOMExceptionCode::kInvalidStateError,
kActiveImmersiveSession));
} }
// All immersive sessions require a user gesture. // All immersive sessions require a user gesture.
bool has_user_activation = LocalFrame::HasTransientUserActivation(frame); bool has_user_activation = LocalFrame::HasTransientUserActivation(frame);
if (is_immersive && !has_user_activation) { if (is_immersive && !has_user_activation) {
ReportRequestSessionResult(session_mode, SessionRequestStatus::kOtherError); query->Reject(MakeGarbageCollected<DOMException>(
return ScriptPromise::RejectWithDOMException( DOMExceptionCode::kSecurityError, kRequestRequiresUserActivation));
script_state, return promise;
MakeGarbageCollected<DOMException>(DOMExceptionCode::kSecurityError,
kRequestRequiresUserActivation));
} }
// TODO(https://crbug.com/962991): The error handling here is not spec // TODO(https://crbug.com/962991): The error handling here is not spec
...@@ -318,19 +380,11 @@ ScriptPromise XR::requestSession(ScriptState* script_state, ...@@ -318,19 +380,11 @@ ScriptPromise XR::requestSession(ScriptState* script_state,
// it was for an inline mode. In which case, we'll end up creating the // it was for an inline mode. In which case, we'll end up creating the
// session in OnRequestSessionReturned. // session in OnRequestSessionReturned.
if (!service_ && session_mode != XRSession::kModeInline) { if (!service_ && session_mode != XRSession::kModeInline) {
ReportRequestSessionResult(session_mode, SessionRequestStatus::kOtherError); query->Reject(MakeGarbageCollected<DOMException>(
return ScriptPromise::RejectWithDOMException( DOMExceptionCode::kNotSupportedError, kNoDevicesMessage));
script_state, return promise;
MakeGarbageCollected<DOMException>(DOMExceptionCode::kNotSupportedError,
kNoDevicesMessage));
} }
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise();
PendingSessionQuery* query =
MakeGarbageCollected<PendingSessionQuery>(resolver, session_mode);
if (!device_) { if (!device_) {
pending_session_requests_.push_back(query); pending_session_requests_.push_back(query);
...@@ -343,7 +397,7 @@ ScriptPromise XR::requestSession(ScriptState* script_state, ...@@ -343,7 +397,7 @@ ScriptPromise XR::requestSession(ScriptState* script_state,
return promise; return promise;
} }
void XR::DispatchRequestSession(PendingSessionQuery* query) { void XR::DispatchRequestSession(PendingRequestSessionQuery* query) {
// TODO(https://crbug.com/968622): Make sure we don't forget to call // TODO(https://crbug.com/968622): Make sure we don't forget to call
// metrics-related methods when the promise gets resolved/rejected. // metrics-related methods when the promise gets resolved/rejected.
...@@ -352,25 +406,23 @@ void XR::DispatchRequestSession(PendingSessionQuery* query) { ...@@ -352,25 +406,23 @@ void XR::DispatchRequestSession(PendingSessionQuery* query) {
// hardware. Attempt to create a sensorless session. // hardware. Attempt to create a sensorless session.
// TODO(https://crbug.com/944987): When device_ is eliminated, unify with // TODO(https://crbug.com/944987): When device_ is eliminated, unify with
// OnRequestSessionReturned() and inline CreateSensorlessInlineSession(). // OnRequestSessionReturned() and inline CreateSensorlessInlineSession().
if (query->mode == XRSession::kModeInline) { if (query->mode() == XRSession::kModeInline) {
XRSession* session = CreateSensorlessInlineSession(); XRSession* session = CreateSensorlessInlineSession();
ReportRequestSessionResult(query->mode, SessionRequestStatus::kSuccess); query->Resolve(session);
query->resolver->Resolve(session);
return; return;
} }
ReportRequestSessionResult(query->mode, SessionRequestStatus::kOtherError);
// TODO(https://crbug.com/962991): The spec says to reject with null. // TODO(https://crbug.com/962991): The spec says to reject with null.
// Clarify/fix the spec. In other places where we have no device or no // Clarify/fix the spec. In other places where we have no device or no
// service we return kNotSupportedError. // service we return kNotSupportedError.
query->resolver->Reject(MakeGarbageCollected<DOMException>( query->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, kSessionNotSupported)); DOMExceptionCode::kNotSupportedError, kSessionNotSupported));
return; return;
} }
device::mojom::blink::XRSessionOptionsPtr session_options = device::mojom::blink::XRSessionOptionsPtr session_options =
convertModeToMojo(query->mode); convertModeToMojo(query->mode());
outstanding_request_queries_.insert(query); outstanding_request_queries_.insert(query);
device_->RequestSession( device_->RequestSession(
...@@ -439,7 +491,7 @@ void XR::DispatchPendingSessionCalls() { ...@@ -439,7 +491,7 @@ void XR::DispatchPendingSessionCalls() {
pending_session_requests_.clear(); pending_session_requests_.clear();
} }
void XR::OnSupportsSessionReturned(PendingSessionQuery* query, void XR::OnSupportsSessionReturned(PendingSupportsSessionQuery* query,
bool supports_session) { bool supports_session) {
// The session query has returned and we're about to resolve or reject the // The session query has returned and we're about to resolve or reject the
// promise, so remove it from our outstanding list. // promise, so remove it from our outstanding list.
...@@ -447,13 +499,13 @@ void XR::OnSupportsSessionReturned(PendingSessionQuery* query, ...@@ -447,13 +499,13 @@ void XR::OnSupportsSessionReturned(PendingSessionQuery* query,
outstanding_support_queries_.erase(query); outstanding_support_queries_.erase(query);
supports_session supports_session
? query->resolver->Resolve() ? query->Resolve()
: query->resolver->Reject(MakeGarbageCollected<DOMException>( : query->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, kSessionNotSupported)); DOMExceptionCode::kNotSupportedError, kSessionNotSupported));
} }
void XR::OnRequestSessionReturned( void XR::OnRequestSessionReturned(
PendingSessionQuery* query, PendingRequestSessionQuery* query,
device::mojom::blink::XRSessionPtr session_ptr) { device::mojom::blink::XRSessionPtr session_ptr) {
// The session query has returned and we're about to resolve or reject the // The session query has returned and we're about to resolve or reject the
// promise, so remove it from our outstanding list. // promise, so remove it from our outstanding list.
...@@ -467,23 +519,20 @@ void XR::OnRequestSessionReturned( ...@@ -467,23 +519,20 @@ void XR::OnRequestSessionReturned(
// sensorless session. // sensorless session.
// TODO(https://crbug.com/944987): When device_ is eliminated, unify with // TODO(https://crbug.com/944987): When device_ is eliminated, unify with
// DispatchRequestSession() and inline CreateSensorlessInlineSession(). // DispatchRequestSession() and inline CreateSensorlessInlineSession().
if (query->mode == XRSession::kModeInline) { if (query->mode() == XRSession::kModeInline) {
XRSession* session = CreateSensorlessInlineSession(); XRSession* session = CreateSensorlessInlineSession();
ReportRequestSessionResult(query->mode, SessionRequestStatus::kSuccess); query->Resolve(session);
query->resolver->Resolve(session);
return; return;
} }
ReportRequestSessionResult(query->mode, SessionRequestStatus::kOtherError);
auto* exception = MakeGarbageCollected<DOMException>( auto* exception = MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, kSessionNotSupported); DOMExceptionCode::kNotSupportedError, kSessionNotSupported);
query->resolver->Reject(exception); query->Reject(exception);
return; return;
} }
bool environment_integration = query->mode == XRSession::kModeImmersiveAR; bool environment_integration = query->mode() == XRSession::kModeImmersiveAR;
// immersive sessions must supply display info. // immersive sessions must supply display info.
DCHECK(session_ptr->display_info); DCHECK(session_ptr->display_info);
...@@ -502,12 +551,12 @@ void XR::OnRequestSessionReturned( ...@@ -502,12 +551,12 @@ void XR::OnRequestSessionReturned(
if (environment_integration) if (environment_integration)
blend_mode = XRSession::kBlendModeAlphaBlend; blend_mode = XRSession::kBlendModeAlphaBlend;
XRSession* session = CreateSession(query->mode, blend_mode, XRSession* session = CreateSession(query->mode(), blend_mode,
std::move(session_ptr->client_request), std::move(session_ptr->client_request),
std::move(session_ptr->display_info)); std::move(session_ptr->display_info));
if (query->mode == XRSession::kModeImmersiveVR || if (query->mode() == XRSession::kModeImmersiveVR ||
query->mode == XRSession::kModeImmersiveAR) { query->mode() == XRSession::kModeImmersiveAR) {
frameProvider()->BeginImmersiveSession(session, std::move(session_ptr)); frameProvider()->BeginImmersiveSession(session, std::move(session_ptr));
if (environment_integration) { if (environment_integration) {
// See Task Sources spreadsheet for more information: // See Task Sources spreadsheet for more information:
...@@ -525,11 +574,10 @@ void XR::OnRequestSessionReturned( ...@@ -525,11 +574,10 @@ void XR::OnRequestSessionReturned(
&XR::OnMagicWindowProviderDisconnect, WrapWeakPersistent(this))); &XR::OnMagicWindowProviderDisconnect, WrapWeakPersistent(this)));
} }
UseCounter::Count(ExecutionContext::From(query->resolver->GetScriptState()), UseCounter::Count(ExecutionContext::From(query->GetScriptState()),
WebFeature::kWebXrSessionCreated); WebFeature::kWebXrSessionCreated);
ReportRequestSessionResult(query->mode, SessionRequestStatus::kSuccess); query->Resolve(session);
query->resolver->Resolve(session);
} }
void XR::ReportImmersiveSupported(bool supported) { void XR::ReportImmersiveSupported(bool supported) {
...@@ -542,18 +590,6 @@ void XR::ReportImmersiveSupported(bool supported) { ...@@ -542,18 +590,6 @@ void XR::ReportImmersiveSupported(bool supported) {
} }
} }
void XR::ReportRequestSessionResult(XRSession::SessionMode session_mode,
SessionRequestStatus status) {
Document* doc = GetFrame() ? GetFrame()->GetDocument() : nullptr;
if (!doc)
return;
ukm::builders::XR_WebXR_SessionRequest(GetSourceId())
.SetMode(static_cast<int64_t>(session_mode))
.SetStatus(static_cast<int64_t>(status))
.Record(doc->UkmRecorder());
}
void XR::AddedEventListener(const AtomicString& event_type, void XR::AddedEventListener(const AtomicString& event_type,
RegisteredEventListener& registered_listener) { RegisteredEventListener& registered_listener) {
EventTargetWithInlineData::AddedEventListener(event_type, EventTargetWithInlineData::AddedEventListener(event_type,
...@@ -632,14 +668,14 @@ void XR::OnDeviceDisconnect() { ...@@ -632,14 +668,14 @@ void XR::OnDeviceDisconnect() {
device_ = nullptr; device_ = nullptr;
HeapHashSet<Member<PendingSessionQuery>> support_queries = HeapHashSet<Member<PendingSupportsSessionQuery>> support_queries =
outstanding_support_queries_; outstanding_support_queries_;
for (const auto& query : support_queries) { for (const auto& query : support_queries) {
OnSupportsSessionReturned(query, false); OnSupportsSessionReturned(query, false);
} }
DCHECK(outstanding_support_queries_.IsEmpty()); DCHECK(outstanding_support_queries_.IsEmpty());
HeapHashSet<Member<PendingSessionQuery>> request_queries = HeapHashSet<Member<PendingRequestSessionQuery>> request_queries =
outstanding_request_queries_; outstanding_request_queries_;
for (const auto& query : request_queries) { for (const auto& query : request_queries) {
// We had a device, so rejecting the session request as though the mode // We had a device, so rejecting the session request as though the mode
......
...@@ -86,30 +86,81 @@ class XR final : public EventTargetWithInlineData, ...@@ -86,30 +86,81 @@ class XR final : public EventTargetWithInlineData,
kMaxValue = kOtherError, kMaxValue = kOtherError,
}; };
class PendingSessionQuery final // Encapsulates blink-side `XR::requestSession()` call. It is a wrapper around
: public GarbageCollected<PendingSessionQuery> { // ScriptPromiseResolver that allows us to add additional logic as certain
DISALLOW_COPY_AND_ASSIGN(PendingSessionQuery); // things related to promise's life cycle happen.
class PendingRequestSessionQuery final
: public GarbageCollected<PendingRequestSessionQuery> {
DISALLOW_COPY_AND_ASSIGN(PendingRequestSessionQuery);
public: public:
PendingSessionQuery(ScriptPromiseResolver*, XRSession::SessionMode); PendingRequestSessionQuery(int64_t ukm_source_id,
virtual ~PendingSessionQuery() = default; ScriptPromiseResolver* resolver,
XRSession::SessionMode mode);
virtual ~PendingRequestSessionQuery() = default;
// Resolves underlying promise with passed in XR session.
void Resolve(XRSession* session);
// Rejects underlying promise with passed in DOM exception.
void Reject(DOMException* exception);
// Rejects underlying promise with passed in v8 value. Used to raise
// TypeError which is not a DOM exception.
void Reject(v8::Local<v8::Value> value);
XRSession::SessionMode mode() const;
// Returns underlying resolver's script state.
ScriptState* GetScriptState() const;
virtual void Trace(blink::Visitor*); virtual void Trace(blink::Visitor*);
Member<ScriptPromiseResolver> resolver; private:
const XRSession::SessionMode mode; void ReportRequestSessionResult(SessionRequestStatus status);
bool has_user_activation = false;
Member<ScriptPromiseResolver> resolver_;
const XRSession::SessionMode mode_;
const int64_t ukm_source_id_;
};
// Encapsulates blink-side `XR::supportsSession()` call. It is a wrapper
// around ScriptPromiseResolver that allows us to add additional logic as
// certain things related to promise's life cycle happen.
class PendingSupportsSessionQuery final
: public GarbageCollected<PendingSupportsSessionQuery> {
DISALLOW_COPY_AND_ASSIGN(PendingSupportsSessionQuery);
public:
PendingSupportsSessionQuery(ScriptPromiseResolver*, XRSession::SessionMode);
virtual ~PendingSupportsSessionQuery() = default;
// Resolves underlying promise.
void Resolve();
// Rejects underlying promise with passed in DOM exception.
void Reject(DOMException* exception);
// Rejects underlying promise with passed in v8 value. Used to raise
// TypeError which is not a DOM exception.
void Reject(v8::Local<v8::Value> value);
XRSession::SessionMode mode() const;
virtual void Trace(blink::Visitor*);
private:
Member<ScriptPromiseResolver> resolver_;
const XRSession::SessionMode mode_;
}; };
void OnRequestDeviceReturned(device::mojom::blink::XRDevicePtr device); void OnRequestDeviceReturned(device::mojom::blink::XRDevicePtr device);
void DispatchPendingSessionCalls(); void DispatchPendingSessionCalls();
void DispatchRequestSession(PendingSessionQuery*); void DispatchRequestSession(PendingRequestSessionQuery*);
void OnRequestSessionReturned(PendingSessionQuery*, void OnRequestSessionReturned(PendingRequestSessionQuery*,
device::mojom::blink::XRSessionPtr); device::mojom::blink::XRSessionPtr);
void DispatchSupportsSession(PendingSessionQuery*); void DispatchSupportsSession(PendingSupportsSessionQuery*);
void OnSupportsSessionReturned(PendingSessionQuery*, bool supports_session); void OnSupportsSessionReturned(PendingSupportsSessionQuery*,
bool supports_session);
void EnsureDevice(); void EnsureDevice();
void ReportImmersiveSupported(bool supported); void ReportImmersiveSupported(bool supported);
...@@ -148,11 +199,11 @@ class XR final : public EventTargetWithInlineData, ...@@ -148,11 +199,11 @@ class XR final : public EventTargetWithInlineData,
// Track calls that were made prior to the internal device successfully being // Track calls that were made prior to the internal device successfully being
// queried. Can be removed once the service has been updated to allow the // queried. Can be removed once the service has been updated to allow the
// respective calls to be made directly. // respective calls to be made directly.
HeapVector<Member<PendingSessionQuery>> pending_mode_queries_; HeapVector<Member<PendingSupportsSessionQuery>> pending_mode_queries_;
HeapVector<Member<PendingSessionQuery>> pending_session_requests_; HeapVector<Member<PendingRequestSessionQuery>> pending_session_requests_;
HeapHashSet<Member<PendingSessionQuery>> outstanding_support_queries_; HeapHashSet<Member<PendingSupportsSessionQuery>> outstanding_support_queries_;
HeapHashSet<Member<PendingSessionQuery>> outstanding_request_queries_; HeapHashSet<Member<PendingRequestSessionQuery>> outstanding_request_queries_;
Vector<EnvironmentProviderErrorCallback> Vector<EnvironmentProviderErrorCallback>
environment_provider_error_callbacks_; environment_provider_error_callbacks_;
......
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