| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 // These dispatchers must use Clone() instead of std::move to ensure that | 160 // These dispatchers must use Clone() instead of std::move to ensure that |
| 161 // if there are multiple registered services they all get a copy of the data. | 161 // if there are multiple registered services they all get a copy of the data. |
| 162 void VRDeviceManager::OnDeviceChanged(VRDisplayPtr device) { | 162 void VRDeviceManager::OnDeviceChanged(VRDisplayPtr device) { |
| 163 for (const auto& service : services_) | 163 for (const auto& service : services_) |
| 164 service->client()->OnDisplayChanged(device.Clone()); | 164 service->client()->OnDisplayChanged(device.Clone()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool VRDeviceManager::RequestPresent(VRServiceImpl* service, | 167 bool VRDeviceManager::RequestPresent(VRServiceImpl* service, |
| 168 unsigned int index) { | 168 unsigned int index, |
| 169 bool secure_origin) { |
| 169 // Is anything presenting currently? | 170 // Is anything presenting currently? |
| 170 if (presenting_service_) { | 171 if (presenting_service_) { |
| 171 // Should never have a presenting service without a presenting device. | 172 // Should never have a presenting service without a presenting device. |
| 172 DCHECK(presenting_device_); | 173 DCHECK(presenting_device_); |
| 173 | 174 |
| 174 // Fail if the currently presenting service is not the one making the | 175 // Fail if the currently presenting service is not the one making the |
| 175 // request. | 176 // request. |
| 176 if (presenting_service_ != service) | 177 if (presenting_service_ != service) |
| 177 return false; | 178 return false; |
| 178 | 179 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 191 presenting_service_ = nullptr; | 192 presenting_service_ = nullptr; |
| 192 } | 193 } |
| 193 | 194 |
| 194 VRDevice* requested_device = GetDevice(index); | 195 VRDevice* requested_device = GetDevice(index); |
| 195 // Can't present to a device that doesn't exist. | 196 // Can't present to a device that doesn't exist. |
| 196 if (!requested_device) | 197 if (!requested_device) |
| 197 return false; | 198 return false; |
| 198 | 199 |
| 199 // Attempt to begin presenting to this device. This could fail for any number | 200 // Attempt to begin presenting to this device. This could fail for any number |
| 200 // of device-specific reasons. | 201 // of device-specific reasons. |
| 201 if (!requested_device->RequestPresent()) | 202 if (!requested_device->RequestPresent(secure_origin)) |
| 202 return false; | 203 return false; |
| 203 | 204 |
| 204 // Successfully began presenting! | 205 // Successfully began presenting! |
| 205 presenting_service_ = service; | 206 presenting_service_ = service; |
| 206 presenting_device_ = requested_device; | 207 presenting_device_ = requested_device; |
| 207 | 208 |
| 208 return true; | 209 return true; |
| 209 } | 210 } |
| 210 | 211 |
| 211 void VRDeviceManager::ExitPresent(VRServiceImpl* service, unsigned int index) { | 212 void VRDeviceManager::ExitPresent(VRServiceImpl* service, unsigned int index) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 for (const auto& provider : providers_) | 314 for (const auto& provider : providers_) |
| 314 provider->PollEvents(); | 315 provider->PollEvents(); |
| 315 } | 316 } |
| 316 | 317 |
| 317 void VRDeviceManager::StopSchedulingPollEvents() { | 318 void VRDeviceManager::StopSchedulingPollEvents() { |
| 318 if (has_scheduled_poll_) | 319 if (has_scheduled_poll_) |
| 319 timer_.Stop(); | 320 timer_.Stop(); |
| 320 } | 321 } |
| 321 | 322 |
| 322 } // namespace device | 323 } // namespace device |
| OLD | NEW |