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

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

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Created 4 years, 1 month 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 device_manager->presenting_device_->id() == index) 72 device_manager->presenting_device_->id() == index)
73 return nullptr; 73 return nullptr;
74 } 74 }
75 75
76 return device_manager->GetDevice(index); 76 return device_manager->GetDevice(index);
77 } 77 }
78 78
79 void VRDeviceManager::SetInstance(VRDeviceManager* instance) { 79 void VRDeviceManager::SetInstance(VRDeviceManager* instance) {
80 // Unit tests can create multiple instances but only one should exist at any 80 // Unit tests can create multiple instances but only one should exist at any
81 // given time so g_vr_device_manager should only go from nullptr to 81 // given time so g_vr_device_manager should only go from nullptr to
82 // non-nullptr and vica versa. 82 // non-nullptr and vice versa.
83 CHECK_NE(!!instance, !!g_vr_device_manager); 83 CHECK_NE(!!instance, !!g_vr_device_manager);
84 g_vr_device_manager = instance; 84 g_vr_device_manager = instance;
85 } 85 }
86 86
87 bool VRDeviceManager::HasInstance() { 87 bool VRDeviceManager::HasInstance() {
88 // For testing. Checks to see if a VRDeviceManager instance is active. 88 // For testing. Checks to see if a VRDeviceManager instance is active.
89 return !!g_vr_device_manager; 89 return !!g_vr_device_manager;
90 } 90 }
91 91
92 void VRDeviceManager::AddService(VRServiceImpl* service) { 92 void VRDeviceManager::AddService(VRServiceImpl* service) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DCHECK(presenting_service_); 280 DCHECK(presenting_service_);
281 281
282 // Notify the presenting service that it's been forced to end presentation. 282 // Notify the presenting service that it's been forced to end presentation.
283 presenting_service_->client()->OnExitPresent(device->id()); 283 presenting_service_->client()->OnExitPresent(device->id());
284 284
285 // Clear the presenting service and device. 285 // Clear the presenting service and device.
286 presenting_service_ = nullptr; 286 presenting_service_ = nullptr;
287 presenting_device_ = nullptr; 287 presenting_device_ = nullptr;
288 } 288 }
289 289
290 void VRDeviceManager::PausePresent(VRDevice* device) {
291 // Ensure the presenting device is the one that we've been requested to pause.
292 if (!presenting_device_ || presenting_device_ != device)
293 return;
294
295 // Should never have a presenting device without a presenting service.
296 DCHECK(presenting_service_);
297
298 // Notify the presenting service that it should pause.
299 presenting_service_->client()->OnPausePresent(device->id());
300 }
301
302 void VRDeviceManager::ResumePresent(VRDevice* device) {
303 // Ensure the presenting device is the one that we've been requested to
304 // resume.
305 if (!presenting_device_ || presenting_device_ != device)
306 return;
307
308 // Should never have a presenting device without a presenting service.
309 DCHECK(presenting_service_);
310
311 // Notify the presenting service that it should pause.
312 presenting_service_->client()->OnResumePresent(device->id());
313 }
314
290 void VRDeviceManager::InitializeProviders() { 315 void VRDeviceManager::InitializeProviders() {
291 if (vr_initialized_) { 316 if (vr_initialized_) {
292 return; 317 return;
293 } 318 }
294 319
295 for (const auto& provider : providers_) { 320 for (const auto& provider : providers_) {
296 provider->SetClient(this); 321 provider->SetClient(this);
297 provider->Initialize(); 322 provider->Initialize();
298 } 323 }
299 324
(...skipping 19 matching lines...) Expand all
319 for (const auto& provider : providers_) 344 for (const auto& provider : providers_)
320 provider->PollEvents(); 345 provider->PollEvents();
321 } 346 }
322 347
323 void VRDeviceManager::StopSchedulingPollEvents() { 348 void VRDeviceManager::StopSchedulingPollEvents() {
324 if (has_scheduled_poll_) 349 if (has_scheduled_poll_)
325 timer_.Stop(); 350 timer_.Stop();
326 } 351 }
327 352
328 } // namespace device 353 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698