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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2537723002: Refine VRDevice Class (Closed)
Patch Set: Rebase Created 4 years 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_display_impl_unittest.cc ('k') | device/vr/vr_service_impl_unittest.cc » ('j') | 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 49ddde0482efb074ec3eb3977ea272730a3a817e..8be4a83e1660bb0aabeedd5429f67eec8559cfa0 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -37,16 +37,27 @@ VRDisplayImpl* VRServiceImpl::GetVRDisplayImpl(VRDevice* device) {
}
void VRServiceImpl::Bind(mojo::InterfaceRequest<mojom::VRService> request) {
- // TODO(shaobo.yan@intel.com) : Keep one binding_ and use close and rebind.
- binding_.reset(new mojo::Binding<mojom::VRService>(this, std::move(request)));
+ if (!binding_)
+ binding_.reset(
+ new mojo::Binding<mojom::VRService>(this, std::move(request)));
+ else
+ binding_->Bind(std::move(request));
binding_->set_connection_error_handler(base::Bind(
&VRServiceImpl::RemoveFromDeviceManager, base::Unretained(this)));
}
void VRServiceImpl::RemoveFromDeviceManager() {
- displays_.clear();
+ // Remove VRDisplayImpl in service/device pair.
+ // displays_ is a map which first element is a VRDevice pointer,
+ // the second element is a VRDisplayImpl pointer.
+ for (DisplayImplMap::iterator it = displays_.begin(); it != displays_.end();
+ ++it) {
+ it->first->RemoveDisplay(it->second.get());
+ }
+
VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
device_manager->RemoveService(this);
+ displays_.clear();
}
void VRServiceImpl::RemoveDevice(VRDevice* device) {
@@ -56,7 +67,6 @@ void VRServiceImpl::RemoveDevice(VRDevice* device) {
void VRServiceImpl::SetClient(mojom::VRServiceClientPtr service_client,
const 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
« no previous file with comments | « device/vr/vr_display_impl_unittest.cc ('k') | device/vr/vr_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698