| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/vr/vr_device_manager.h" | 5 #include "device/vr/vr_device_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 device_manager->presenting_device_->id() == index) | 72 device_manager->presenting_device_->id() == index) |
| 73 return nullptr; | 73 return nullptr; |
| 74 } | 74 } |
| 75 | 75 |
| 76 return device_manager->GetDevice(index); | 76 return device_manager->GetDevice(index); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void VRDeviceManager::SetInstance(VRDeviceManager* instance) { | 79 void VRDeviceManager::SetInstance(VRDeviceManager* instance) { |
| 80 // Unit tests can create multiple instances but only one should exist at any | 80 // Unit tests can create multiple instances but only one should exist at any |
| 81 // given time so g_vr_device_manager should only go from nullptr to | 81 // given time so g_vr_device_manager should only go from nullptr to |
| 82 // non-nullptr and vica versa. | 82 // non-nullptr and vice versa. |
| 83 CHECK_NE(!!instance, !!g_vr_device_manager); | 83 CHECK_NE(!!instance, !!g_vr_device_manager); |
| 84 g_vr_device_manager = instance; | 84 g_vr_device_manager = instance; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool VRDeviceManager::HasInstance() { | 87 bool VRDeviceManager::HasInstance() { |
| 88 // For testing. Checks to see if a VRDeviceManager instance is active. | 88 // For testing. Checks to see if a VRDeviceManager instance is active. |
| 89 return !!g_vr_device_manager; | 89 return !!g_vr_device_manager; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void VRDeviceManager::AddService(VRServiceImpl* service) { | 92 void VRDeviceManager::AddService(VRServiceImpl* service) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 DCHECK(presenting_service_); | 280 DCHECK(presenting_service_); |
| 281 | 281 |
| 282 // Notify the presenting service that it's been forced to end presentation. | 282 // Notify the presenting service that it's been forced to end presentation. |
| 283 presenting_service_->client()->OnExitPresent(device->id()); | 283 presenting_service_->client()->OnExitPresent(device->id()); |
| 284 | 284 |
| 285 // Clear the presenting service and device. | 285 // Clear the presenting service and device. |
| 286 presenting_service_ = nullptr; | 286 presenting_service_ = nullptr; |
| 287 presenting_device_ = nullptr; | 287 presenting_device_ = nullptr; |
| 288 } | 288 } |
| 289 | 289 |
| 290 void VRDeviceManager::OnDisplayBlur(VRDevice* device) { |
| 291 // Ensure the presenting device is the one that we've been requested to blur. |
| 292 if (!presenting_device_ || presenting_device_ != device) |
| 293 return; |
| 294 |
| 295 // Should never have a presenting device without a presenting service. |
| 296 DCHECK(presenting_service_); |
| 297 |
| 298 // Notify the presenting service that it should blur. |
| 299 presenting_service_->client()->OnDisplayBlur(device->id()); |
| 300 } |
| 301 |
| 302 void VRDeviceManager::OnDisplayFocus(VRDevice* device) { |
| 303 // Ensure the presenting device is the one that we've been requested to focus. |
| 304 if (!presenting_device_ || presenting_device_ != device) |
| 305 return; |
| 306 |
| 307 // Should never have a presenting device without a presenting service. |
| 308 DCHECK(presenting_service_); |
| 309 |
| 310 // Notify the presenting service that it should focus. |
| 311 presenting_service_->client()->OnDisplayFocus(device->id()); |
| 312 } |
| 313 |
| 290 void VRDeviceManager::InitializeProviders() { | 314 void VRDeviceManager::InitializeProviders() { |
| 291 if (vr_initialized_) { | 315 if (vr_initialized_) { |
| 292 return; | 316 return; |
| 293 } | 317 } |
| 294 | 318 |
| 295 for (const auto& provider : providers_) { | 319 for (const auto& provider : providers_) { |
| 296 provider->SetClient(this); | 320 provider->SetClient(this); |
| 297 provider->Initialize(); | 321 provider->Initialize(); |
| 298 } | 322 } |
| 299 | 323 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 319 for (const auto& provider : providers_) | 343 for (const auto& provider : providers_) |
| 320 provider->PollEvents(); | 344 provider->PollEvents(); |
| 321 } | 345 } |
| 322 | 346 |
| 323 void VRDeviceManager::StopSchedulingPollEvents() { | 347 void VRDeviceManager::StopSchedulingPollEvents() { |
| 324 if (has_scheduled_poll_) | 348 if (has_scheduled_poll_) |
| 325 timer_.Stop(); | 349 timer_.Stop(); |
| 326 } | 350 } |
| 327 | 351 |
| 328 } // namespace device | 352 } // namespace device |
| OLD | NEW |