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

Unified Diff: device/vr/vr_device_manager.cc

Issue 2510993002: Notify VRDeviceProviders when there are pages listening for vrdisplayactivate (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/vr_device_manager.h ('k') | device/vr/vr_device_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/vr_device_manager.cc
diff --git a/device/vr/vr_device_manager.cc b/device/vr/vr_device_manager.cc
index a1d0144f0d93e356025cc69485026f9d8ee53d66..1f08be9c81e5dd884d8d945ed0e37ff3994549a8 100644
--- a/device/vr/vr_device_manager.cc
+++ b/device/vr/vr_device_manager.cc
@@ -24,7 +24,8 @@ VRDeviceManager* g_vr_device_manager = nullptr;
VRDeviceManager::VRDeviceManager()
: vr_initialized_(false),
keep_alive_(false),
- has_scheduled_poll_(false) {
+ has_scheduled_poll_(false),
+ has_activate_listeners_(false) {
// Register VRDeviceProviders for the current platform
#if defined(OS_ANDROID)
RegisterProvider(base::MakeUnique<GvrDeviceProvider>());
@@ -80,6 +81,10 @@ void VRDeviceManager::RemoveService(VRServiceImpl* service) {
device.second->RemoveService(service);
}
+ if (service->listening_for_activate()) {
+ ListeningForActivateChanged(false);
+ }
+
if (services_.empty() && !keep_alive_) {
// Delete the device manager when it has no active connections.
delete g_vr_device_manager;
@@ -117,6 +122,27 @@ unsigned int VRDeviceManager::GetNumberOfConnectedDevices() {
return static_cast<unsigned int>(devices_.size());
}
+void VRDeviceManager::ListeningForActivateChanged(bool listening) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ bool activate_listeners = listening;
+ if (!activate_listeners) {
+ for (const auto& service : services_) {
+ if (service->listening_for_activate()) {
+ activate_listeners = true;
+ break;
+ }
+ }
+ }
+
+ // Notify all the providers if this changes
+ if (has_activate_listeners_ != activate_listeners) {
+ has_activate_listeners_ = activate_listeners;
+ for (const auto& provider : providers_)
+ provider->SetListeningForActivate(has_activate_listeners_);
+ }
+}
+
VRDevice* VRDeviceManager::GetDevice(unsigned int index) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « device/vr/vr_device_manager.h ('k') | device/vr/vr_device_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698