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

Unified Diff: device/vr/vr_device_manager.cc

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Address comments 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
Index: device/vr/vr_device_manager.cc
diff --git a/device/vr/vr_device_manager.cc b/device/vr/vr_device_manager.cc
index b8c99ea3566c19e288ae011494bb6a1e7add6f04..db7000f59e6c274f2500ac89a89a70238ba7f6e6 100644
--- a/device/vr/vr_device_manager.cc
+++ b/device/vr/vr_device_manager.cc
@@ -29,18 +29,18 @@ VRDeviceManager::VRDeviceManager()
has_scheduled_poll_(false) {
// Register VRDeviceProviders for the current platform
#if defined(OS_ANDROID)
- RegisterProvider(base::WrapUnique(new GvrDeviceProvider()));
+ RegisterProvider(new GvrDeviceProvider());
#endif
}
-VRDeviceManager::VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider)
+VRDeviceManager::VRDeviceManager(VRDeviceProvider* provider)
dcheng 2016/11/08 23:05:45 This should be a scoped_refptr<VRDeviceProvider>.
mthiesse 2016/11/10 22:14:10 Done.
: vr_initialized_(false),
presenting_service_(nullptr),
presenting_device_(nullptr),
keep_alive_(true),
has_scheduled_poll_(false) {
thread_checker_.DetachFromThread();
- RegisterProvider(std::move(provider));
+ RegisterProvider(provider);
SetInstance(this);
}
@@ -79,7 +79,7 @@ VRDevice* VRDeviceManager::GetAllowedDevice(VRServiceImpl* service,
void VRDeviceManager::SetInstance(VRDeviceManager* instance) {
// Unit tests can create multiple instances but only one should exist at any
// given time so g_vr_device_manager should only go from nullptr to
- // non-nullptr and vica versa.
+ // non-nullptr and vice versa.
CHECK_NE(!!instance, !!g_vr_device_manager);
g_vr_device_manager = instance;
}
@@ -287,6 +287,30 @@ void VRDeviceManager::OnPresentEnded(VRDevice* device) {
presenting_device_ = nullptr;
}
+void VRDeviceManager::OnDisplayBlur(VRDevice* device) {
+ // Ensure the presenting device is the one that we've been requested to blur.
+ if (!presenting_device_ || presenting_device_ != device)
+ return;
+
+ // Should never have a presenting device without a presenting service.
+ DCHECK(presenting_service_);
+
+ // Notify the presenting service that it should blur.
+ presenting_service_->client()->OnDisplayBlur(device->id());
+}
+
+void VRDeviceManager::OnDisplayFocus(VRDevice* device) {
+ // Ensure the presenting device is the one that we've been requested to focus.
+ if (!presenting_device_ || presenting_device_ != device)
+ return;
+
+ // Should never have a presenting device without a presenting service.
+ DCHECK(presenting_service_);
+
+ // Notify the presenting service that it should focus.
+ presenting_service_->client()->OnDisplayFocus(device->id());
+}
+
void VRDeviceManager::InitializeProviders() {
if (vr_initialized_) {
return;
@@ -300,9 +324,8 @@ void VRDeviceManager::InitializeProviders() {
vr_initialized_ = true;
}
-void VRDeviceManager::RegisterProvider(
- std::unique_ptr<VRDeviceProvider> provider) {
- providers_.push_back(make_linked_ptr(provider.release()));
+void VRDeviceManager::RegisterProvider(VRDeviceProvider* provider) {
dcheng 2016/11/08 23:05:45 Ditto: this should also be a scoped_refptr<VRDevic
mthiesse 2016/11/10 22:14:10 Done.
+ providers_.push_back(provider);
}
void VRDeviceManager::SchedulePollEvents() {

Powered by Google App Engine
This is Rietveld 408576698