| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "device/vr/vr_device.h" | 8 #include "device/vr/vr_device.h" |
| 9 #include "device/vr/vr_service_impl.h" | 9 #include "device/vr/vr_service_impl.h" |
| 10 | 10 |
| 11 namespace device { | 11 namespace device { |
| 12 | 12 |
| 13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service) | 13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service) |
| 14 : binding_(this), | 14 : binding_(this), |
| 15 device_(device), | 15 device_(device), |
| 16 service_(service), | 16 service_(service), |
| 17 weak_ptr_factory_(this) { | 17 weak_ptr_factory_(this) { |
| 18 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice(); | 18 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice(); |
| 19 // Client might be null in unittest. | 19 // Client might be null in unittest. |
| 20 // TODO: setup a mock client in unittest too? | 20 // TODO: setup a mock client in unittest too? |
| 21 if (service->client()) { | 21 if (service->client()) { |
| 22 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), | 22 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), |
| 23 mojo::GetProxy(&client_), | 23 mojo::GetProxy(&client_), |
| 24 std::move(display_info)); | 24 std::move(display_info)); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 VRDisplayImpl::~VRDisplayImpl() {} | 28 VRDisplayImpl::~VRDisplayImpl() { |
| 29 device_->RemoveService(service_); |
| 30 } |
| 29 | 31 |
| 30 void VRDisplayImpl::GetPose(const GetPoseCallback& callback) { | 32 void VRDisplayImpl::GetPose(const GetPoseCallback& callback) { |
| 31 if (!device_->IsAccessAllowed(service_)) { | 33 if (!device_->IsAccessAllowed(service_)) { |
| 32 callback.Run(nullptr); | 34 callback.Run(nullptr); |
| 33 return; | 35 return; |
| 34 } | 36 } |
| 35 | 37 |
| 36 callback.Run(device_->GetPose()); | 38 callback.Run(device_->GetPose()); |
| 37 } | 39 } |
| 38 | 40 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 79 } |
| 78 | 80 |
| 79 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, | 81 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, |
| 80 mojom::VRLayerBoundsPtr right_bounds) { | 82 mojom::VRLayerBoundsPtr right_bounds) { |
| 81 if (!device_->IsAccessAllowed(service_)) | 83 if (!device_->IsAccessAllowed(service_)) |
| 82 return; | 84 return; |
| 83 | 85 |
| 84 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds)); | 86 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds)); |
| 85 } | 87 } |
| 86 } | 88 } |
| OLD | NEW |