OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | 5 #ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_ |
6 #define DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | 6 #define DEVICE_USB_DEVICE_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "device/usb/public/interfaces/device_manager.mojom.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" | 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" | 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
17 | 17 |
| 18 namespace base { |
| 19 class SequencedTaskRunner; |
| 20 } |
| 21 |
| 22 namespace mojo { |
| 23 class ErrorHandler; |
| 24 } |
| 25 |
18 namespace device { | 26 namespace device { |
19 | 27 |
20 class UsbDevice; | 28 class UsbDevice; |
21 class UsbDeviceFilter; | 29 class UsbDeviceFilter; |
22 class UsbDeviceHandle; | 30 class UsbDeviceHandle; |
23 | 31 |
24 namespace usb { | 32 namespace usb { |
25 | 33 |
26 class DeviceManagerDelegate; | 34 class DeviceManagerDelegate; |
27 | 35 |
28 // Implementation of the public DeviceManager interface. Clients in the browser | 36 // Implementation of the public DeviceManager interface. This interface can be |
29 // can connect to this service via DeviceClient::ConnectToUSBDeviceManager. | 37 // requested from the devices app located at "system:devices", if available. |
30 class DeviceManagerImpl : public DeviceManager { | 38 class DeviceManagerImpl : public DeviceManager { |
31 public: | 39 public: |
32 DeviceManagerImpl(mojo::InterfaceRequest<DeviceManager> request, | 40 DeviceManagerImpl( |
33 scoped_ptr<DeviceManagerDelegate> delegate); | 41 mojo::InterfaceRequest<DeviceManager> request, |
| 42 scoped_ptr<DeviceManagerDelegate> delegate, |
| 43 scoped_refptr<base::SequencedTaskRunner> service_task_runner); |
34 ~DeviceManagerImpl() override; | 44 ~DeviceManagerImpl() override; |
35 | 45 |
| 46 void set_error_handler(mojo::ErrorHandler* error_handler); |
| 47 |
36 private: | 48 private: |
37 // DeviceManager implementation: | 49 // DeviceManager implementation: |
38 void GetDevices(EnumerationOptionsPtr options, | 50 void GetDevices(EnumerationOptionsPtr options, |
39 const GetDevicesCallback& callback) override; | 51 const GetDevicesCallback& callback) override; |
40 void OpenDevice(const mojo::String& guid, | 52 void OpenDevice(const mojo::String& guid, |
41 mojo::InterfaceRequest<Device> device_request, | 53 mojo::InterfaceRequest<Device> device_request, |
42 const OpenDeviceCallback& callback) override; | 54 const OpenDeviceCallback& callback) override; |
43 | 55 |
44 // Callback to handle the async response from the underlying UsbService. | 56 // Callback to handle the async response from the underlying UsbService. |
45 void OnGetDevices(const GetDevicesCallback& callback, | 57 void OnGetDevices(EnumerationOptionsPtr options, |
46 const std::vector<UsbDeviceFilter>& filters, | 58 const GetDevicesCallback& callback, |
47 const std::vector<scoped_refptr<UsbDevice>>& devices); | 59 const std::vector<scoped_refptr<UsbDevice>>& devices); |
48 | 60 |
49 // Callback to handle the async Open response from a UsbDevice. | |
50 void OnOpenDevice(const OpenDeviceCallback& callback, | |
51 mojo::InterfaceRequest<Device> device_request, | |
52 scoped_refptr<UsbDeviceHandle> device_handle); | |
53 | |
54 mojo::StrongBinding<DeviceManager> binding_; | 61 mojo::StrongBinding<DeviceManager> binding_; |
55 | 62 |
56 scoped_ptr<DeviceManagerDelegate> delegate_; | 63 scoped_ptr<DeviceManagerDelegate> delegate_; |
| 64 scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
57 | 65 |
58 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_; | 66 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_; |
59 | 67 |
60 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl); | 68 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl); |
61 }; | 69 }; |
62 | 70 |
63 } // namespace usb | 71 } // namespace usb |
64 } // namespace device | 72 } // namespace device |
65 | 73 |
66 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | 74 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ |
OLD | NEW |