1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_
6 #define DEVICE_USB_DEVICE_MANAGER_IMPL_H_
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
19 class SequencedTaskRunner
;
25 class UsbDeviceFilter
;
26 class UsbDeviceHandle
;
30 class DeviceManagerDelegate
;
32 // Implementation of the public DeviceManager interface. This interface can be
33 // requested from the devices app located at "system:devices", if available.
34 class DeviceManagerImpl
: public DeviceManager
{
37 mojo::InterfaceRequest
<DeviceManager
> request
,
38 scoped_ptr
<DeviceManagerDelegate
> delegate
,
39 scoped_refptr
<base::SequencedTaskRunner
> service_task_runner
);
40 ~DeviceManagerImpl() override
;
42 void set_connection_error_handler(const mojo::Closure
& error_handler
);
45 // DeviceManager implementation:
46 void GetDevices(EnumerationOptionsPtr options
,
47 const GetDevicesCallback
& callback
) override
;
48 void OpenDevice(const mojo::String
& guid
,
49 mojo::InterfaceRequest
<Device
> device_request
,
50 const OpenDeviceCallback
& callback
) override
;
52 // Callback to handle the async response from the underlying UsbService.
53 void OnGetDevices(EnumerationOptionsPtr options
,
54 const GetDevicesCallback
& callback
,
55 const std::vector
<scoped_refptr
<UsbDevice
>>& devices
);
57 mojo::StrongBinding
<DeviceManager
> binding_
;
59 scoped_ptr
<DeviceManagerDelegate
> delegate_
;
60 scoped_refptr
<base::SequencedTaskRunner
> service_task_runner_
;
62 base::WeakPtrFactory
<DeviceManagerImpl
> weak_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl
);
70 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_