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

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

Issue 2343023002: Switch WebVR to handle GvrApi management through VrShellDelegate (Closed)
Patch Set: Renamed onNativeLibraryReady to initializeNative Created 4 years, 3 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_service.mojom » ('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/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (device->id() == VR_DEVICE_LAST_ID) 127 if (device->id() == VR_DEVICE_LAST_ID)
128 continue; 128 continue;
129 129
130 if (devices_.find(device->id()) == devices_.end()) 130 if (devices_.find(device->id()) == devices_.end())
131 devices_[device->id()] = device; 131 devices_[device->id()] = device;
132 132
133 VRDisplayPtr vr_device_info = device->GetVRDevice(); 133 VRDisplayPtr vr_device_info = device->GetVRDevice();
134 if (vr_device_info.is_null()) 134 if (vr_device_info.is_null())
135 continue; 135 continue;
136 136
137 vr_device_info->index = device->id(); 137 // GetVRDevice should always set the index of the VRDisplay to its own id.
138 DCHECK(vr_device_info->index == device->id());
139
138 out_devices.push_back(std::move(vr_device_info)); 140 out_devices.push_back(std::move(vr_device_info));
139 } 141 }
140 142
141 return out_devices; 143 return out_devices;
142 } 144 }
143 145
144 VRDevice* VRDeviceManager::GetDevice(unsigned int index) { 146 VRDevice* VRDeviceManager::GetDevice(unsigned int index) {
145 DCHECK(thread_checker_.CalledOnValidThread()); 147 DCHECK(thread_checker_.CalledOnValidThread());
146 148
147 if (index == 0) { 149 if (index == 0) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 vr_device_info->index = device->id(); 258 vr_device_info->index = device->id();
257 259
258 for (const auto& service : services_) 260 for (const auto& service : services_)
259 service->client()->OnDisplayConnected(vr_device_info.Clone()); 261 service->client()->OnDisplayConnected(vr_device_info.Clone());
260 } else { 262 } else {
261 for (const auto& service : services_) 263 for (const auto& service : services_)
262 service->client()->OnDisplayDisconnected(device->id()); 264 service->client()->OnDisplayDisconnected(device->id());
263 } 265 }
264 } 266 }
265 267
268 void VRDeviceManager::OnPresentEnded(VRDevice* device) {
269 // Ensure the presenting device is the one that we've been requested to stop.
270 if (!presenting_device_ || presenting_device_ != device)
271 return;
272
273 // Should never have a presenting device without a presenting service.
274 DCHECK(presenting_service_);
275
276 // Notify the presenting service that it's been forced to end presentation.
277 presenting_service_->client()->OnExitPresent(device->id());
278
279 // Clear the presenting service and device.
280 presenting_service_ = nullptr;
281 presenting_device_ = nullptr;
282 }
283
266 void VRDeviceManager::InitializeProviders() { 284 void VRDeviceManager::InitializeProviders() {
267 if (vr_initialized_) { 285 if (vr_initialized_) {
268 return; 286 return;
269 } 287 }
270 288
271 for (const auto& provider : providers_) { 289 for (const auto& provider : providers_) {
272 provider->SetClient(this); 290 provider->SetClient(this);
273 provider->Initialize(); 291 provider->Initialize();
274 } 292 }
275 293
(...skipping 19 matching lines...) Expand all
295 for (const auto& provider : providers_) 313 for (const auto& provider : providers_)
296 provider->PollEvents(); 314 provider->PollEvents();
297 } 315 }
298 316
299 void VRDeviceManager::StopSchedulingPollEvents() { 317 void VRDeviceManager::StopSchedulingPollEvents() {
300 if (has_scheduled_poll_) 318 if (has_scheduled_poll_)
301 timer_.Stop(); 319 timer_.Stop();
302 } 320 }
303 321
304 } // namespace device 322 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/vr_device_manager.h ('k') | device/vr/vr_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698