summaryrefslogtreecommitdiffstats
path: root/device/usb/mojo/device_manager_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'device/usb/mojo/device_manager_impl.h')
-rw-r--r--device/usb/mojo/device_manager_impl.h39
1 files changed, 12 insertions, 27 deletions
diff --git a/device/usb/mojo/device_manager_impl.h b/device/usb/mojo/device_manager_impl.h
index 85e46ce..6ddf5d1 100644
--- a/device/usb/mojo/device_manager_impl.h
+++ b/device/usb/mojo/device_manager_impl.h
@@ -14,7 +14,6 @@
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "device/usb/public/interfaces/device_manager.mojom.h"
-#include "device/usb/public/interfaces/permission_provider.mojom.h"
#include "device/usb/usb_service.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -32,20 +31,17 @@ class UsbDeviceHandle;
namespace usb {
-class DeviceManagerDelegate;
+class PermissionProvider;
// Implementation of the public DeviceManager interface. This interface can be
// requested from the devices app located at "mojo:devices", if available.
-class DeviceManagerImpl : public DeviceManager,
- public device::UsbService::Observer {
+class DeviceManagerImpl : public DeviceManager, public UsbService::Observer {
public:
- using DeviceList = std::vector<scoped_refptr<UsbDevice>>;
- using DeviceMap = std::map<std::string, scoped_refptr<device::UsbDevice>>;
-
- static void Create(PermissionProviderPtr permission_provider,
+ static void Create(base::WeakPtr<PermissionProvider> permission_provider,
mojo::InterfaceRequest<DeviceManager> request);
- DeviceManagerImpl(PermissionProviderPtr permission_provider,
+ DeviceManagerImpl(base::WeakPtr<PermissionProvider> permission_provider,
+ UsbService* usb_service,
mojo::InterfaceRequest<DeviceManager> request);
~DeviceManagerImpl() override;
@@ -62,40 +58,29 @@ class DeviceManagerImpl : public DeviceManager,
mojo::InterfaceRequest<Device> device_request) override;
// Callbacks to handle the async responses from the underlying UsbService.
- void OnGetDevicePermissionCheckComplete(
- scoped_refptr<device::UsbDevice> device,
- mojo::InterfaceRequest<Device> device_request,
- mojo::Array<mojo::String> allowed_guids);
void OnGetDevices(EnumerationOptionsPtr options,
const GetDevicesCallback& callback,
- const DeviceList& devices);
+ const std::vector<scoped_refptr<UsbDevice>>& devices);
// UsbService::Observer implementation:
- void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override;
- void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
+ void OnDeviceAdded(scoped_refptr<UsbDevice> device) override;
+ void OnDeviceRemoved(scoped_refptr<UsbDevice> device) override;
void WillDestroyUsbService() override;
void MaybeRunDeviceChangesCallback();
- void OnEnumerationPermissionCheckComplete(
- const DeviceMap& devices_added,
- const DeviceMap& devices_removed,
- mojo::Array<mojo::String> allowed_guids);
- PermissionProviderPtr permission_provider_;
+ base::WeakPtr<PermissionProvider> permission_provider_;
// If there are unfinished calls to GetDeviceChanges their callbacks
// are stored in |device_change_callbacks_|. Otherwise device changes
// are collected in |devices_added_| and |devices_removed_| until the
// next call to GetDeviceChanges.
std::queue<GetDeviceChangesCallback> device_change_callbacks_;
- DeviceMap devices_added_;
- DeviceMap devices_removed_;
- // To ensure that GetDeviceChangesCallbacks are called in the correct order
- // only perform a single request to |permission_provider_| at a time.
- bool permission_request_pending_ = false;
+ std::map<std::string, DeviceInfoPtr> devices_added_;
+ std::vector<DeviceInfoPtr> devices_removed_;
UsbService* usb_service_;
- ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
+ ScopedObserver<UsbService, UsbService::Observer> observer_;
mojo::Closure connection_error_handler_;