| 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 "content/browser/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/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 | 12 |
| 13 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 14 #include "content/browser/vr/android/cardboard/cardboard_vr_device_provider.h" | 14 #include "device/vr/android/cardboard/cardboard_vr_device_provider.h" |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 namespace content { | 17 namespace device { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 VRDeviceManager* g_vr_device_manager = nullptr; | 20 VRDeviceManager* g_vr_device_manager = nullptr; |
| 21 } | 21 } |
| 22 | 22 |
| 23 VRDeviceManager::VRDeviceManager() | 23 VRDeviceManager::VRDeviceManager() |
| 24 : vr_initialized_(false), keep_alive_(false) { | 24 : vr_initialized_(false), keep_alive_(false) { |
| 25 bindings_.set_connection_error_handler( | 25 bindings_.set_connection_error_handler( |
| 26 base::Bind(&VRDeviceManager::OnConnectionError, base::Unretained(this))); | 26 base::Bind(&VRDeviceManager::OnConnectionError, base::Unretained(this))); |
| 27 // Register VRDeviceProviders for the current platform | 27 // Register VRDeviceProviders for the current platform |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 void VRDeviceManager::RegisterProvider( | 133 void VRDeviceManager::RegisterProvider( |
| 134 std::unique_ptr<VRDeviceProvider> provider) { | 134 std::unique_ptr<VRDeviceProvider> provider) { |
| 135 providers_.push_back(make_linked_ptr(provider.release())); | 135 providers_.push_back(make_linked_ptr(provider.release())); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void VRDeviceManager::GetDisplays(const GetDisplaysCallback& callback) { | 138 void VRDeviceManager::GetDisplays(const GetDisplaysCallback& callback) { |
| 139 callback.Run(GetVRDevices()); | 139 callback.Run(GetVRDevices()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void VRDeviceManager::GetPose(uint32_t index, | 142 void VRDeviceManager::GetPose(uint32_t index, const GetPoseCallback& callback) { |
| 143 const GetPoseCallback& callback) { | |
| 144 VRDevice* device = GetDevice(index); | 143 VRDevice* device = GetDevice(index); |
| 145 if (device) { | 144 if (device) { |
| 146 callback.Run(device->GetPose()); | 145 callback.Run(device->GetPose()); |
| 147 } else { | 146 } else { |
| 148 callback.Run(nullptr); | 147 callback.Run(nullptr); |
| 149 } | 148 } |
| 150 } | 149 } |
| 151 | 150 |
| 152 void VRDeviceManager::ResetPose(uint32_t index) { | 151 void VRDeviceManager::ResetPose(uint32_t index) { |
| 153 VRDevice* device = GetDevice(index); | 152 VRDevice* device = GetDevice(index); |
| 154 if (device) | 153 if (device) |
| 155 device->ResetPose(); | 154 device->ResetPose(); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace content | 157 } // namespace device |
| OLD | NEW |