| 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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 DCHECK(displays_.count(device) == 0); | 47 DCHECK(displays_.count(device) == 0); |
| 48 base::Callback<void(mojom::VRDisplayInfoPtr)> on_created = | 48 base::Callback<void(mojom::VRDisplayInfoPtr)> on_created = |
| 49 base::Bind(&VRServiceImpl::OnVRDisplayInfoCreated, | 49 base::Bind(&VRServiceImpl::OnVRDisplayInfoCreated, |
| 50 weak_ptr_factory_.GetWeakPtr(), device); | 50 weak_ptr_factory_.GetWeakPtr(), device); |
| 51 device->CreateVRDisplayInfo(on_created); | 51 device->CreateVRDisplayInfo(on_created); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void VRServiceImpl::SetListeningForActivate(bool listening) { | 54 void VRServiceImpl::SetListeningForActivate(bool listening) { |
| 55 listening_for_activate_ = listening; | 55 listening_for_activate_ = listening; |
| 56 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); | 56 VRDeviceManager* device_manager = VRDeviceManager::GetInstance(); |
| 57 device_manager->ListeningForActivateChanged(listening); | 57 device_manager->ListeningForActivateChanged(listening, this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Creates a VRDisplayPtr unique to this service so that the associated page can | 60 // Creates a VRDisplayPtr unique to this service so that the associated page can |
| 61 // communicate with the VRDevice. | 61 // communicate with the VRDevice. |
| 62 void VRServiceImpl::OnVRDisplayInfoCreated( | 62 void VRServiceImpl::OnVRDisplayInfoCreated( |
| 63 VRDevice* device, | 63 VRDevice* device, |
| 64 mojom::VRDisplayInfoPtr display_info) { | 64 mojom::VRDisplayInfoPtr display_info) { |
| 65 // TODO(crbug/701027): make sure that client_ is never null by initializing it | 65 // TODO(crbug/701027): make sure that client_ is never null by initializing it |
| 66 // in the constructor. | 66 // in the constructor. |
| 67 if (!client_) { | 67 if (!client_) { |
| 68 DLOG(ERROR) << "Cannot create VR display because connection to render " | 68 DLOG(ERROR) << "Cannot create VR display because connection to render " |
| 69 "process is not established"; | 69 "process is not established"; |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 displays_[device] = base::MakeUnique<VRDisplayImpl>( | 72 displays_[device] = base::MakeUnique<VRDisplayImpl>( |
| 73 device, this, client_.get(), std::move(display_info)); | 73 device, this, client_.get(), std::move(display_info)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 VRDisplayImpl* VRServiceImpl::GetVRDisplayImplForTesting(VRDevice* device) { | 76 VRDisplayImpl* VRServiceImpl::GetVRDisplayImplForTesting(VRDevice* device) { |
| 77 auto it = displays_.find(device); | 77 auto it = displays_.find(device); |
| 78 return (it == displays_.end()) ? nullptr : it->second.get(); | 78 return (it == displays_.end()) ? nullptr : it->second.get(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace device | 81 } // namespace device |
| OLD | NEW |