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

Unified Diff: device/vr/vr_service_impl.cc

Issue 2590883003: Fix leak in VRServiceImpl (Closed)
Patch Set: fix compile 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_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 49ddde0482efb074ec3eb3977ea272730a3a817e..0dd7e7fa43b87563767962c45228c48d3a810c4d 100644
--- a/device/vr/vr_service_impl.cc
+++ b/device/vr/vr_service_impl.cc
@@ -9,25 +9,25 @@
#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() {
- RemoveFromDeviceManager();
+ VRDeviceManager::GetInstance()->RemoveService(this);
}
-void VRServiceImpl::BindRequest(
- mojo::InterfaceRequest<mojom::VRService> request) {
- VRServiceImpl* service = new VRServiceImpl();
- service->Bind(std::move(request));
+void VRServiceImpl::Create(mojo::InterfaceRequest<mojom::VRService> request) {
+ mojo::MakeStrongBinding(base::MakeUnique<VRServiceImpl>(),
+ 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) {
- DisplayImplMap::iterator it = displays_.find(device);
+ auto it = displays_.find(device);
if (it != displays_.end())
return it->second.get();
@@ -36,19 +36,6 @@ VRDisplayImpl* VRServiceImpl::GetVRDisplayImpl(VRDevice* device) {
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) {
displays_.erase(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