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/array.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
20 class SequencedTaskRunner
;
26 class UsbDeviceFilter
;
27 class UsbDeviceHandle
;
31 class DeviceManagerDelegate
;
33 // Implementation of the public DeviceManager interface. This interface can be
34 // requested from the devices app located at "mojo:devices", if available.
35 class DeviceManagerImpl
: public DeviceManager
{
38 mojo::InterfaceRequest
<DeviceManager
> request
,
39 scoped_ptr
<DeviceManagerDelegate
> delegate
,
40 scoped_refptr
<base::SequencedTaskRunner
> service_task_runner
);
41 ~DeviceManagerImpl() override
;
43 void set_connection_error_handler(const mojo::Closure
& error_handler
);
46 // DeviceManager implementation:
47 void GetDevices(EnumerationOptionsPtr options
,
48 const GetDevicesCallback
& callback
) override
;
49 void OpenDevice(const mojo::String
& guid
,
50 mojo::InterfaceRequest
<Device
> device_request
,
51 const OpenDeviceCallback
& callback
) override
;
53 // Callback to handle the async response from the underlying UsbService.
54 void OnGetDevices(const GetDevicesCallback
& callback
,
55 mojo::Array
<DeviceInfoPtr
> 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_