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

Unified Diff: device/usb/mojo/device_manager_impl.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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/usb/mojo/device_manager_impl.h ('k') | device/usb/mojo/device_manager_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/mojo/device_manager_impl.cc
diff --git a/device/usb/mojo/device_manager_impl.cc b/device/usb/mojo/device_manager_impl.cc
index 1f6625db8c0fb980feefaf51880c3fc3038689a2..767d63310e713b9e5b1b24b42c834c0c9b05dc8c 100644
--- a/device/usb/mojo/device_manager_impl.cc
+++ b/device/usb/mojo/device_manager_impl.cc
@@ -21,6 +21,7 @@
#include "mojo/common/common_type_converters.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
namespace device {
namespace usb {
@@ -32,18 +33,18 @@ void DeviceManagerImpl::Create(
DCHECK(DeviceClient::Get());
UsbService* usb_service = DeviceClient::Get()->GetUsbService();
if (usb_service) {
- new DeviceManagerImpl(permission_provider, usb_service, std::move(request));
+ mojo::MakeStrongBinding(
+ base::MakeUnique<DeviceManagerImpl>(permission_provider, usb_service),
+ std::move(request));
}
}
DeviceManagerImpl::DeviceManagerImpl(
base::WeakPtr<PermissionProvider> permission_provider,
- UsbService* usb_service,
- mojo::InterfaceRequest<DeviceManager> request)
+ UsbService* usb_service)
: permission_provider_(permission_provider),
usb_service_(usb_service),
observer_(this),
- binding_(this, std::move(request)),
weak_factory_(this) {
// This object owns itself and will be destroyed if the message pipe it is
// bound to is closed, the message loop is destructed, or the UsbService is
@@ -72,6 +73,7 @@ void DeviceManagerImpl::GetDevice(
if (permission_provider_ &&
permission_provider_->HasDevicePermission(device)) {
+ // Owns itself.
new DeviceImpl(device, DeviceInfo::From(*device), permission_provider_,
std::move(device_request));
}
« no previous file with comments | « device/usb/mojo/device_manager_impl.h ('k') | device/usb/mojo/device_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698