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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2916423002: [WebVR] Handle slow connecting devices. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/vr/vr_service_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/vr_service_impl.cc
diff --git a/device/vr/vr_service_impl.cc b/device/vr/vr_service_impl.cc
index 81223facf67b42ffa95c448277be8149ab6201ce..5f51669c9c3ddd06ac08711ce1ead4e4485ad3c6 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -17,6 +17,7 @@ namespace device {
VRServiceImpl::VRServiceImpl()
: listening_for_activate_(false),
connected_devices_(0),
+ handled_devices_(0),
weak_ptr_factory_(this) {}
VRServiceImpl::~VRServiceImpl() {
@@ -41,8 +42,18 @@ void VRServiceImpl::SetClient(mojom::VRServiceClientPtr service_client,
// send ConnectDevice to it so that it's populated with the currently active
// displays. Thereafter it will stay up to date by virtue of listening for new
// connected events.
- VRDeviceManager::GetInstance()->AddService(this);
- std::move(callback).Run(connected_devices_);
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ device_manager->AddService(this);
+ unsigned expected_devices = device_manager->GetNumberOfConnectedDevices();
+ // TODO(amp): Remove this count based synchronization.
+ // If libraries are not loaded, new devices will immediatly be handled but not
+ // connect, return only those devices which have already connected.
+ // If libraries were loaded then all devices may not be handled yet so return
+ // the number we expect to eventually connect.
+ if (expected_devices == handled_devices_) {
+ expected_devices = connected_devices_;
+ }
+ std::move(callback).Run(expected_devices);
mthiesse 2017/06/05 16:18:07 I'm confused. Doesn't this just re-introduce the b
amp 2017/06/05 16:31:18 Let me attempt a better explanation (let me know i
}
void VRServiceImpl::ConnectDevice(VRDevice* device) {
@@ -72,15 +83,16 @@ void VRServiceImpl::OnVRDisplayInfoCreated(
return;
}
- if (!display_info) {
- // If we get passed a null display info it means the device does not exist.
- // This can happen for example if VR services are not installed. We will not
- // instantiate a display in this case and don't count it as connected.
- return;
+ // If we get passed a null display info it means the device does not exist.
+ // This can happen for example if VR services are not installed. We will not
+ // instantiate a display in this case and don't count it as connected, but we
+ // do mark that we have handled it.
+ if (display_info) {
+ displays_[device] = base::MakeUnique<VRDisplayImpl>(
+ device, this, client_.get(), std::move(display_info));
+ connected_devices_++;
}
mthiesse 2017/06/05 17:36:27 Can we DCHECK on the else case there we're inside
amp 2017/06/05 18:40:39 Done. Switched the if around (back to the origina
- displays_[device] = base::MakeUnique<VRDisplayImpl>(
- device, this, client_.get(), std::move(display_info));
- connected_devices_++;
+ handled_devices_++;
}
VRDisplayImpl* VRServiceImpl::GetVRDisplayImplForTesting(VRDevice* device) {
« no previous file with comments | « device/vr/vr_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698