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 9b5be90ee8c1d6eeca3e479436fb6969fa93ed18..4aff6ce54860890f749df2ec638836a32b48f671 100644 |
--- a/device/vr/android/gvr/gvr_device_provider.cc |
+++ b/device/vr/android/gvr/gvr_device_provider.cc |
@@ -33,14 +33,9 @@ |
} |
void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { |
- devices->push_back(vr_device_.get()); |
-} |
- |
-device::GvrDelegateProvider* GvrDeviceProvider::GetDelegateProvider() { |
- device::GvrDelegateProvider* provider = |
- device::GvrDelegateProvider::GetInstance(); |
- Initialize(provider); |
- return provider; |
+ Initialize(); |
+ if (initialized_) |
+ devices->push_back(vr_device_.get()); |
} |
void GvrDeviceProvider::Initialize() { |
@@ -48,36 +43,41 @@ |
// GvrDeviceProvider so we don't have to call this function multiple times. |
// Ideally the DelegateProvider would always be available, and GetInstance() |
// would create it. |
- Initialize(device::GvrDelegateProvider::GetInstance()); |
-} |
- |
-void GvrDeviceProvider::Initialize(device::GvrDelegateProvider* provider) { |
- if (!provider) |
+ if (initialized_) |
return; |
- provider->SetDeviceProvider(this); |
+ device::GvrDelegateProvider* delegate_provider = |
+ device::GvrDelegateProvider::GetInstance(); |
+ if (!delegate_provider) |
+ return; |
+ delegate_provider->SetDeviceProvider(this); |
+ initialized_ = true; |
} |
void GvrDeviceProvider::RequestPresent( |
- mojom::VRSubmitFrameClientPtr submit_client, |
const base::Callback<void(bool)>& callback) { |
- device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); |
+ Initialize(); |
+ device::GvrDelegateProvider* delegate_provider = |
+ device::GvrDelegateProvider::GetInstance(); |
if (!delegate_provider) |
return callback.Run(false); |
// RequestWebVRPresent is async as we may trigger a DON flow that pauses |
// Chrome. |
- delegate_provider->RequestWebVRPresent(std::move(submit_client), callback); |
+ delegate_provider->RequestWebVRPresent(callback); |
} |
// VR presentation exit requested by the API. |
void GvrDeviceProvider::ExitPresent() { |
- device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); |
+ Initialize(); |
+ GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance(); |
if (delegate_provider) |
delegate_provider->ExitWebVRPresent(); |
} |
void GvrDeviceProvider::SetListeningForActivate(bool listening) { |
- device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); |
+ Initialize(); |
+ device::GvrDelegateProvider* delegate_provider = |
+ device::GvrDelegateProvider::GetInstance(); |
if (!delegate_provider) |
return; |