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/devices_app/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 { | 18 namespace base { |
19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
20 } | 20 } |
21 | 21 |
22 namespace mojo { | |
23 class ErrorHandler; | |
24 } | |
25 | |
26 namespace device { | 22 namespace device { |
27 | 23 |
28 class UsbDevice; | 24 class UsbDevice; |
29 class UsbDeviceFilter; | 25 class UsbDeviceFilter; |
30 class UsbDeviceHandle; | 26 class UsbDeviceHandle; |
31 | 27 |
32 namespace usb { | 28 namespace usb { |
33 | 29 |
34 class DeviceManagerDelegate; | 30 class DeviceManagerDelegate; |
35 | 31 |
36 // Implementation of the public DeviceManager interface. This interface can be | 32 // Implementation of the public DeviceManager interface. This interface can be |
37 // requested from the devices app located at "system:devices", if available. | 33 // requested from the devices app located at "system:devices", if available. |
38 class DeviceManagerImpl : public DeviceManager { | 34 class DeviceManagerImpl : public DeviceManager { |
39 public: | 35 public: |
40 DeviceManagerImpl( | 36 DeviceManagerImpl( |
41 mojo::InterfaceRequest<DeviceManager> request, | 37 mojo::InterfaceRequest<DeviceManager> request, |
42 scoped_ptr<DeviceManagerDelegate> delegate, | 38 scoped_ptr<DeviceManagerDelegate> delegate, |
43 scoped_refptr<base::SequencedTaskRunner> service_task_runner); | 39 scoped_refptr<base::SequencedTaskRunner> service_task_runner); |
44 ~DeviceManagerImpl() override; | 40 ~DeviceManagerImpl() override; |
45 | 41 |
46 void set_error_handler(mojo::ErrorHandler* error_handler); | 42 void set_connection_error_handler(const mojo::Closure& error_handler); |
47 | 43 |
48 private: | 44 private: |
49 // DeviceManager implementation: | 45 // DeviceManager implementation: |
50 void GetDevices(EnumerationOptionsPtr options, | 46 void GetDevices(EnumerationOptionsPtr options, |
51 const GetDevicesCallback& callback) override; | 47 const GetDevicesCallback& callback) override; |
52 void OpenDevice(const mojo::String& guid, | 48 void OpenDevice(const mojo::String& guid, |
53 mojo::InterfaceRequest<Device> device_request, | 49 mojo::InterfaceRequest<Device> device_request, |
54 const OpenDeviceCallback& callback) override; | 50 const OpenDeviceCallback& callback) override; |
55 | 51 |
56 // Callback to handle the async response from the underlying UsbService. | 52 // Callback to handle the async response from the underlying UsbService. |
57 void OnGetDevices(EnumerationOptionsPtr options, | 53 void OnGetDevices(EnumerationOptionsPtr options, |
58 const GetDevicesCallback& callback, | 54 const GetDevicesCallback& callback, |
59 const std::vector<scoped_refptr<UsbDevice>>& devices); | 55 const std::vector<scoped_refptr<UsbDevice>>& devices); |
60 | 56 |
61 mojo::StrongBinding<DeviceManager> binding_; | 57 mojo::StrongBinding<DeviceManager> binding_; |
62 | 58 |
63 scoped_ptr<DeviceManagerDelegate> delegate_; | 59 scoped_ptr<DeviceManagerDelegate> delegate_; |
64 scoped_refptr<base::SequencedTaskRunner> service_task_runner_; | 60 scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
65 | 61 |
66 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_; | 62 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_; |
67 | 63 |
68 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl); | 64 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl); |
69 }; | 65 }; |
70 | 66 |
71 } // namespace usb | 67 } // namespace usb |
72 } // namespace device | 68 } // namespace device |
73 | 69 |
74 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | 70 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ |
OLD | NEW |