| 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 "device/vr/vr_service_impl.h" | 5 #include "device/vr/vr_service_impl.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" |
| 11 #include "device/vr/vr_device.h" | 11 #include "device/vr/vr_device.h" |
| 12 #include "device/vr/vr_device_manager.h" | 12 #include "device/vr/vr_device_manager.h" |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 14 | 14 |
| 15 namespace device { | 15 namespace device { |
| 16 | 16 |
| 17 VRServiceImpl::VRServiceImpl() : listening_for_activate_(false) {} | 17 VRServiceImpl::VRServiceImpl() : listening_for_activate_(false) {} |
| 18 | 18 |
| 19 VRServiceImpl::~VRServiceImpl() { | 19 VRServiceImpl::~VRServiceImpl() { |
| 20 // Destroy VRDisplay before calling RemoveService below. RemoveService might |
| 21 // implicitly trigger destory VRDevice which VRDisplay needs to access in its |
| 22 // dtor. |
| 23 displays_.clear(); |
| 20 VRDeviceManager::GetInstance()->RemoveService(this); | 24 VRDeviceManager::GetInstance()->RemoveService(this); |
| 21 } | 25 } |
| 22 | 26 |
| 23 void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) { | 27 void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) { |
| 24 mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(), | 28 mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(), |
| 25 std::move(request)); | 29 std::move(request)); |
| 26 } | 30 } |
| 27 | 31 |
| 28 // Gets a VRDisplayPtr unique to this service so that the associated page can | 32 // Gets a VRDisplayPtr unique to this service so that the associated page can |
| 29 // communicate with the VRDevice. | 33 // communicate with the VRDevice. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 54 callback.Run(device_manager->GetNumberOfConnectedDevices()); | 58 callback.Run(device_manager->GetNumberOfConnectedDevices()); |
| 55 } | 59 } |
| 56 | 60 |
| 57 void VRServiceImpl::SetListeningForActivate(bool listening) { | 61 void VRServiceImpl::SetListeningForActivate(bool listening) { |
| 58 listening_for_activate_ = listening; | 62 listening_for_activate_ = listening; |
| 59 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 63 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 60 device_manager->ListeningForActivateChanged(listening); | 64 device_manager->ListeningForActivateChanged(listening); |
| 61 } | 65 } |
| 62 | 66 |
| 63 } // namespace device | 67 } // namespace device |
| OLD | NEW |