Commit 850e5fd2 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Create SessionRequestData struct for VRService

The "RequestSession" flow for a typical VR Session requires bouncing
calls through a few asynchronous API's via callbacks. Currently there
are four pieces of data which get constantly passed through these
callbacks, as they needed at various stages of the request flow.

Unfortunately, since a second "RequestSession" request may come in
during this asynchronous work, this data cannot just be cached on the
VRService class.

This change cleans up some of the pattern to make this more readable by
creating a struct to hold this data, so that only one object needs to
be consistently forwarded around by the code.

Bug: 1045130
Change-Id: I4a64eaba2944ddfe4304a20e023acc0100c834f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024267
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736192}
parent 2b09b822
......@@ -87,6 +87,25 @@ class VRServiceImpl : public device::mojom::VRService,
content::WebContents* GetWebContents();
private:
struct SessionRequestData {
device::mojom::XRSessionOptionsPtr options;
device::mojom::VRService::RequestSessionCallback callback;
std::set<device::mojom::XRSessionFeature> enabled_features;
device::mojom::XRDeviceId runtime_id;
SessionRequestData(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
std::set<device::mojom::XRSessionFeature> enabled_features,
device::mojom::XRDeviceId runtime_id);
~SessionRequestData();
SessionRequestData(SessionRequestData&&);
private:
SessionRequestData(const SessionRequestData&) = delete;
SessionRequestData& operator=(const SessionRequestData&) = delete;
};
// content::WebContentsObserver implementation
void OnWebContentsFocused(content::RenderWidgetHost* host) override;
void OnWebContentsLostFocus(content::RenderWidgetHost* host) override;
......@@ -102,57 +121,40 @@ class VRServiceImpl : public device::mojom::VRService,
SessionMetricsHelper* GetSessionMetricsHelper();
bool InternalSupportsSession(device::mojom::XRSessionOptions* options);
void OnInlineSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController> controller);
void OnImmersiveSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session);
void OnSessionCreated(
device::mojom::XRSessionOptionsPtr options,
device::mojom::XRDeviceId session_runtime_id,
device::mojom::VRService::RequestSessionCallback callback,
const std::set<device::mojom::XRSessionFeature>& enabled_features,
device::mojom::XRSessionPtr session,
WebXRSessionTracker* session_metrics_tracker);
void DoRequestSession(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> enabled_features);
void ShowConsentPrompt(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
BrowserXRRuntime* runtime,
std::set<device::mojom::XRSessionFeature> requested_features);
void OnConsentResult(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
device::mojom::XRDeviceId expected_runtime_id,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
bool is_consent_granted);
void OnPermissionResult(
device::mojom::XRSessionOptionsPtr options,
device::mojom::VRService::RequestSessionCallback callback,
device::mojom::XRDeviceId expected_runtime_id,
std::set<device::mojom::XRSessionFeature> enabled_features,
XrConsentPromptLevel consent_level,
ContentSetting setting_value);
bool IsConsentGrantedForDevice(device::mojom::XRDeviceId device_id,
XrConsentPromptLevel consent_level);
void AddConsentGrantedDevice(device::mojom::XRDeviceId device_id,
XrConsentPromptLevel consent_level);
// The following steps are ordered in the general flow for "RequestSession"
// If the WebXrPermissionsAPI is enabled ShowConsentPrompt will result in a
// call to OnPermissionResult which feeds into OnConsentResult.
// If ShowConsentPrompt determines that no consent/permission is needed (or
// has already been granted), then it will directly call DoRequestSession.
// DoRequestSession will continue with OnInline or OnImmersive SessionCreated
// depending on the type of SessionCreated.
void ShowConsentPrompt(SessionRequestData request, BrowserXRRuntime* runtime);
void OnConsentResult(SessionRequestData request,
XrConsentPromptLevel consent_level,
bool is_consent_granted);
void OnPermissionResult(SessionRequestData request,
XrConsentPromptLevel consent_level,
ContentSetting setting_value);
void DoRequestSession(SessionRequestData request, BrowserXRRuntime* runtime);
void OnInlineSessionCreated(
SessionRequestData request,
device::mojom::XRSessionPtr session,
mojo::PendingRemote<device::mojom::XRSessionController> controller);
void OnImmersiveSessionCreated(SessionRequestData request,
device::mojom::XRSessionPtr session);
void OnSessionCreated(SessionRequestData request,
device::mojom::XRSessionPtr session,
WebXRSessionTracker* session_metrics_tracker);
scoped_refptr<XRRuntimeManager> runtime_manager_;
mojo::RemoteSet<device::mojom::XRSessionClient> session_clients_;
mojo::Remote<device::mojom::VRServiceClient> service_client_;
......
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