| 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 "content/browser/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" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // non-nullptr and vica versa. | 70 // non-nullptr and vica versa. |
| 71 CHECK_NE(!!instance, !!g_vr_device_manager); | 71 CHECK_NE(!!instance, !!g_vr_device_manager); |
| 72 g_vr_device_manager = instance; | 72 g_vr_device_manager = instance; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool VRDeviceManager::HasInstance() { | 75 bool VRDeviceManager::HasInstance() { |
| 76 // For testing. Checks to see if a VRDeviceManager instance is active. | 76 // For testing. Checks to see if a VRDeviceManager instance is active. |
| 77 return !!g_vr_device_manager; | 77 return !!g_vr_device_manager; |
| 78 } | 78 } |
| 79 | 79 |
| 80 mojo::Array<VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() { | 80 mojo::Array<mojom::VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() { |
| 81 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
| 82 | 82 |
| 83 InitializeProviders(); | 83 InitializeProviders(); |
| 84 | 84 |
| 85 std::vector<VRDevice*> devices; | 85 std::vector<VRDevice*> devices; |
| 86 for (const auto& provider : providers_) | 86 for (const auto& provider : providers_) |
| 87 provider->GetDevices(&devices); | 87 provider->GetDevices(&devices); |
| 88 | 88 |
| 89 mojo::Array<VRDeviceInfoPtr> out_devices; | 89 mojo::Array<mojom::VRDeviceInfoPtr> out_devices; |
| 90 for (const auto& device : devices) { | 90 for (const auto& device : devices) { |
| 91 if (device->id() == VR_DEVICE_LAST_ID) | 91 if (device->id() == VR_DEVICE_LAST_ID) |
| 92 continue; | 92 continue; |
| 93 | 93 |
| 94 if (devices_.find(device->id()) == devices_.end()) | 94 if (devices_.find(device->id()) == devices_.end()) |
| 95 devices_[device->id()] = device; | 95 devices_[device->id()] = device; |
| 96 | 96 |
| 97 VRDeviceInfoPtr vr_device_info = device->GetVRDevice(); | 97 mojom::VRDeviceInfoPtr vr_device_info = device->GetVRDevice(); |
| 98 if (vr_device_info.is_null()) | 98 if (vr_device_info.is_null()) |
| 99 continue; | 99 continue; |
| 100 | 100 |
| 101 vr_device_info->index = device->id(); | 101 vr_device_info->index = device->id(); |
| 102 out_devices.push_back(std::move(vr_device_info)); | 102 out_devices.push_back(std::move(vr_device_info)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 return out_devices; | 105 return out_devices; |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void VRDeviceManager::ResetSensor(uint32_t index) { | 147 void VRDeviceManager::ResetSensor(uint32_t index) { |
| 148 VRDevice* device = GetDevice(index); | 148 VRDevice* device = GetDevice(index); |
| 149 if (device) | 149 if (device) |
| 150 device->ResetSensor(); | 150 device->ResetSensor(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace content | 153 } // namespace content |
| OLD | NEW |