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

Unified Diff: device/vr/vr_device_manager.cc

Issue 2266793002: Add SchedulePollEvents and PollEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add StopSchedulingPollEvents Created 4 years, 4 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/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 5bd11702f2f14a96b414cade33ffa240ebad35fe..b774ad248b762c7018e36f3040eded2d48ba6e7d 100644
--- a/device/vr/vr_device_manager.cc
+++ b/device/vr/vr_device_manager.cc
@@ -22,7 +22,7 @@ VRDeviceManager* g_vr_device_manager = nullptr;
}
VRDeviceManager::VRDeviceManager()
- : vr_initialized_(false), keep_alive_(false) {
+ : vr_initialized_(false), keep_alive_(false), has_scheduled_poll_(false) {
// Register VRDeviceProviders for the current platform
#if defined(OS_ANDROID)
RegisterProvider(base::WrapUnique(new GvrDeviceProvider()));
@@ -30,7 +30,7 @@ VRDeviceManager::VRDeviceManager()
}
VRDeviceManager::VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider)
- : vr_initialized_(false), keep_alive_(true) {
+ : vr_initialized_(false), keep_alive_(true), has_scheduled_poll_(false) {
thread_checker_.DetachFromThread();
RegisterProvider(std::move(provider));
SetInstance(this);
@@ -38,6 +38,7 @@ VRDeviceManager::VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider)
VRDeviceManager::~VRDeviceManager() {
DCHECK(thread_checker_.CalledOnValidThread());
+ StopSchedulingPollEvents();
g_vr_device_manager = nullptr;
}
@@ -142,4 +143,24 @@ void VRDeviceManager::RegisterProvider(
providers_.push_back(make_linked_ptr(provider.release()));
}
+void VRDeviceManager::SchedulePollEvents() {
+ if (has_scheduled_poll_)
+ return;
+
+ has_scheduled_poll_ = true;
+
+ timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(500), this,
+ &VRDeviceManager::PollEvents);
+}
+
+void VRDeviceManager::PollEvents() {
+ for (const auto& provider : providers_)
+ provider->PollEvents();
+}
+
+void VRDeviceManager::StopSchedulingPollEvents() {
+ if (has_scheduled_poll_)
+ timer_.Stop();
+}
+
} // namespace device
« 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