Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: device/vr/android/gvr/gvr_device_provider.cc

Issue 2729523002: Re-land^2 WebVR compositor bypass via BrowserMain context + mailbox (Closed)
Patch Set: Rebase to 11e28fd6b9380b77273db51ef0b6ccc7ea341944 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/android/gvr/gvr_device_provider.cc
diff --git a/device/vr/android/gvr/gvr_device_provider.cc b/device/vr/android/gvr/gvr_device_provider.cc
index 4aff6ce54860890f749df2ec638836a32b48f671..9b5be90ee8c1d6eeca3e479436fb6969fa93ed18 100644
--- a/device/vr/android/gvr/gvr_device_provider.cc
+++ b/device/vr/android/gvr/gvr_device_provider.cc
@@ -33,9 +33,14 @@ GvrDeviceProvider::~GvrDeviceProvider() {
}
void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
- Initialize();
- if (initialized_)
- devices->push_back(vr_device_.get());
+ devices->push_back(vr_device_.get());
+}
+
+device::GvrDelegateProvider* GvrDeviceProvider::GetDelegateProvider() {
+ device::GvrDelegateProvider* provider =
+ device::GvrDelegateProvider::GetInstance();
+ Initialize(provider);
+ return provider;
}
void GvrDeviceProvider::Initialize() {
@@ -43,41 +48,36 @@ void GvrDeviceProvider::Initialize() {
// GvrDeviceProvider so we don't have to call this function multiple times.
// Ideally the DelegateProvider would always be available, and GetInstance()
// would create it.
- if (initialized_)
+ Initialize(device::GvrDelegateProvider::GetInstance());
+}
+
+void GvrDeviceProvider::Initialize(device::GvrDelegateProvider* provider) {
+ if (!provider)
return;
- device::GvrDelegateProvider* delegate_provider =
- device::GvrDelegateProvider::GetInstance();
- if (!delegate_provider)
- return;
- delegate_provider->SetDeviceProvider(this);
- initialized_ = true;
+ provider->SetDeviceProvider(this);
}
void GvrDeviceProvider::RequestPresent(
+ mojom::VRSubmitFrameClientPtr submit_client,
const base::Callback<void(bool)>& callback) {
- Initialize();
- device::GvrDelegateProvider* delegate_provider =
- device::GvrDelegateProvider::GetInstance();
+ device::GvrDelegateProvider* delegate_provider = GetDelegateProvider();
if (!delegate_provider)
return callback.Run(false);
// RequestWebVRPresent is async as we may trigger a DON flow that pauses
// Chrome.
- delegate_provider->RequestWebVRPresent(callback);
+ delegate_provider->RequestWebVRPresent(std::move(submit_client), callback);
}
// VR presentation exit requested by the API.
void GvrDeviceProvider::ExitPresent() {
- Initialize();
- GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance();
+ device::GvrDelegateProvider* delegate_provider = GetDelegateProvider();
if (delegate_provider)
delegate_provider->ExitWebVRPresent();
}
void GvrDeviceProvider::SetListeningForActivate(bool listening) {
- Initialize();
- device::GvrDelegateProvider* delegate_provider =
- device::GvrDelegateProvider::GetInstance();
+ device::GvrDelegateProvider* delegate_provider = GetDelegateProvider();
if (!delegate_provider)
return;
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698