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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2915993004: [WebVR] Only count devices that have successfully connected. (Closed)
Patch Set: Ignore device manager, just track the connected devices directly from the callbacks 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 7ceb154d80e8bbf40cc9cbb6678941f82ed16f07..81223facf67b42ffa95c448277be8149ab6201ce 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -15,7 +15,9 @@
namespace device {
VRServiceImpl::VRServiceImpl()
- : listening_for_activate_(false), weak_ptr_factory_(this) {}
+ : listening_for_activate_(false),
+ connected_devices_(0),
+ weak_ptr_factory_(this) {}
VRServiceImpl::~VRServiceImpl() {
// Destroy VRDisplay before calling RemoveService below. RemoveService might
@@ -35,13 +37,12 @@ void VRServiceImpl::SetClient(mojom::VRServiceClientPtr service_client,
SetClientCallback callback) {
DCHECK(!client_.get());
client_ = std::move(service_client);
- VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
// Once a client has been connected AddService will force any VRDisplays to
// 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.
- device_manager->AddService(this);
- std::move(callback).Run(device_manager->GetNumberOfConnectedDevices());
+ VRDeviceManager::GetInstance()->AddService(this);
+ std::move(callback).Run(connected_devices_);
}
void VRServiceImpl::ConnectDevice(VRDevice* device) {
@@ -70,14 +71,16 @@ void VRServiceImpl::OnVRDisplayInfoCreated(
"process is not established";
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.
+ // instantiate a display in this case and don't count it as connected.
return;
}
displays_[device] = base::MakeUnique<VRDisplayImpl>(
device, this, client_.get(), std::move(display_info));
+ connected_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