Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: device/vr/vr_device_manager.cc

Issue 2041003003: Moved vr_service.mojom from blink to device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed missing mojo dependency in gyp builds Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/vr/vr_device_manager.h ('k') | device/vr/vr_device_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 26 matching lines...) Expand all
37 thread_checker_.DetachFromThread(); 37 thread_checker_.DetachFromThread();
38 RegisterProvider(std::move(provider)); 38 RegisterProvider(std::move(provider));
39 SetInstance(this); 39 SetInstance(this);
40 } 40 }
41 41
42 VRDeviceManager::~VRDeviceManager() { 42 VRDeviceManager::~VRDeviceManager() {
43 DCHECK(thread_checker_.CalledOnValidThread()); 43 DCHECK(thread_checker_.CalledOnValidThread());
44 g_vr_device_manager = nullptr; 44 g_vr_device_manager = nullptr;
45 } 45 }
46 46
47 void VRDeviceManager::BindRequest( 47 void VRDeviceManager::BindRequest(mojo::InterfaceRequest<VRService> request) {
48 mojo::InterfaceRequest<blink::mojom::VRService> request) {
49 VRDeviceManager* device_manager = GetInstance(); 48 VRDeviceManager* device_manager = GetInstance();
50 device_manager->bindings_.AddBinding(device_manager, std::move(request)); 49 device_manager->bindings_.AddBinding(device_manager, std::move(request));
51 } 50 }
52 51
53 void VRDeviceManager::OnConnectionError() { 52 void VRDeviceManager::OnConnectionError() {
54 DCHECK(thread_checker_.CalledOnValidThread()); 53 DCHECK(thread_checker_.CalledOnValidThread());
55 if (bindings_.empty() && !keep_alive_) { 54 if (bindings_.empty() && !keep_alive_) {
56 // Delete the device manager when it has no active connections. 55 // Delete the device manager when it has no active connections.
57 delete g_vr_device_manager; 56 delete g_vr_device_manager;
58 } 57 }
(...skipping 11 matching lines...) Expand all
70 // non-nullptr and vica versa. 69 // non-nullptr and vica versa.
71 CHECK_NE(!!instance, !!g_vr_device_manager); 70 CHECK_NE(!!instance, !!g_vr_device_manager);
72 g_vr_device_manager = instance; 71 g_vr_device_manager = instance;
73 } 72 }
74 73
75 bool VRDeviceManager::HasInstance() { 74 bool VRDeviceManager::HasInstance() {
76 // For testing. Checks to see if a VRDeviceManager instance is active. 75 // For testing. Checks to see if a VRDeviceManager instance is active.
77 return !!g_vr_device_manager; 76 return !!g_vr_device_manager;
78 } 77 }
79 78
80 mojo::Array<blink::mojom::VRDisplayPtr> VRDeviceManager::GetVRDevices() { 79 mojo::Array<VRDisplayPtr> VRDeviceManager::GetVRDevices() {
81 DCHECK(thread_checker_.CalledOnValidThread()); 80 DCHECK(thread_checker_.CalledOnValidThread());
82 81
83 InitializeProviders(); 82 InitializeProviders();
84 83
85 std::vector<VRDevice*> devices; 84 std::vector<VRDevice*> devices;
86 for (const auto& provider : providers_) 85 for (const auto& provider : providers_)
87 provider->GetDevices(&devices); 86 provider->GetDevices(&devices);
88 87
89 mojo::Array<blink::mojom::VRDisplayPtr> out_devices; 88 mojo::Array<VRDisplayPtr> out_devices;
90 for (const auto& device : devices) { 89 for (const auto& device : devices) {
91 if (device->id() == VR_DEVICE_LAST_ID) 90 if (device->id() == VR_DEVICE_LAST_ID)
92 continue; 91 continue;
93 92
94 if (devices_.find(device->id()) == devices_.end()) 93 if (devices_.find(device->id()) == devices_.end())
95 devices_[device->id()] = device; 94 devices_[device->id()] = device;
96 95
97 blink::mojom::VRDisplayPtr vr_device_info = device->GetVRDevice(); 96 VRDisplayPtr vr_device_info = device->GetVRDevice();
98 if (vr_device_info.is_null()) 97 if (vr_device_info.is_null())
99 continue; 98 continue;
100 99
101 vr_device_info->index = device->id(); 100 vr_device_info->index = device->id();
102 out_devices.push_back(std::move(vr_device_info)); 101 out_devices.push_back(std::move(vr_device_info));
103 } 102 }
104 103
105 return out_devices; 104 return out_devices;
106 } 105 }
107 106
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 147 }
149 } 148 }
150 149
151 void VRDeviceManager::ResetPose(uint32_t index) { 150 void VRDeviceManager::ResetPose(uint32_t index) {
152 VRDevice* device = GetDevice(index); 151 VRDevice* device = GetDevice(index);
153 if (device) 152 if (device)
154 device->ResetPose(); 153 device->ResetPose();
155 } 154 }
156 155
157 } // namespace device 156 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/vr_device_manager.h ('k') | device/vr/vr_device_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698