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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2615723002: Revert of Fix leak in VRServiceImpl (Closed)
Patch Set: Created 3 years, 11 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 0dd7e7fa43b87563767962c45228c48d3a810c4d..49ddde0482efb074ec3eb3977ea272730a3a817e 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -9,31 +9,44 @@
#include "base/bind.h"
#include "device/vr/vr_device.h"
#include "device/vr/vr_device_manager.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
namespace device {
VRServiceImpl::VRServiceImpl() : listening_for_activate_(false) {}
VRServiceImpl::~VRServiceImpl() {
- VRDeviceManager::GetInstance()->RemoveService(this);
+ RemoveFromDeviceManager();
}
-void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) {
- mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(),
- std::move(request));
+void VRServiceImpl::BindRequest(
+ mojo::InterfaceRequest<mojom::VRService> request) {
+ VRServiceImpl* service = new VRServiceImpl();
+ service->Bind(std::move(request));
}
// Gets a VRDisplayPtr unique to this service so that the associated page can
// communicate with the VRDevice.
VRDisplayImpl* VRServiceImpl::GetVRDisplayImpl(VRDevice* device) {
- auto it = displays_.find(device);
+ DisplayImplMap::iterator it = displays_.find(device);
if (it != displays_.end())
return it->second.get();
VRDisplayImpl* display_impl = new VRDisplayImpl(device, this);
displays_[device] = base::WrapUnique(display_impl);
return display_impl;
+}
+
+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)));
+ binding_->set_connection_error_handler(base::Bind(
+ &VRServiceImpl::RemoveFromDeviceManager, base::Unretained(this)));
+}
+
+void VRServiceImpl::RemoveFromDeviceManager() {
+ displays_.clear();
+ VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
+ device_manager->RemoveService(this);
}
void VRServiceImpl::RemoveDevice(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