| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | |
| 6 #define DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 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/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" | |
| 17 | |
| 18 namespace device { | |
| 19 | |
| 20 class UsbDevice; | |
| 21 class UsbDeviceFilter; | |
| 22 class UsbDeviceHandle; | |
| 23 | |
| 24 namespace usb { | |
| 25 | |
| 26 class DeviceManagerDelegate; | |
| 27 | |
| 28 // Implementation of the public DeviceManager interface. Clients in the browser | |
| 29 // can connect to this service via DeviceClient::ConnectToUSBDeviceManager. | |
| 30 class DeviceManagerImpl : public DeviceManager { | |
| 31 public: | |
| 32 DeviceManagerImpl(mojo::InterfaceRequest<DeviceManager> request, | |
| 33 scoped_ptr<DeviceManagerDelegate> delegate); | |
| 34 ~DeviceManagerImpl() override; | |
| 35 | |
| 36 private: | |
| 37 // DeviceManager implementation: | |
| 38 void GetDevices(EnumerationOptionsPtr options, | |
| 39 const GetDevicesCallback& callback) override; | |
| 40 void OpenDevice(const mojo::String& guid, | |
| 41 mojo::InterfaceRequest<Device> device_request, | |
| 42 const OpenDeviceCallback& callback) override; | |
| 43 | |
| 44 // Callback to handle the async response from the underlying UsbService. | |
| 45 void OnGetDevices(const GetDevicesCallback& callback, | |
| 46 const std::vector<UsbDeviceFilter>& filters, | |
| 47 const std::vector<scoped_refptr<UsbDevice>>& devices); | |
| 48 | |
| 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_; | |
| 55 | |
| 56 scoped_ptr<DeviceManagerDelegate> delegate_; | |
| 57 | |
| 58 base::WeakPtrFactory<DeviceManagerImpl> weak_factory_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(DeviceManagerImpl); | |
| 61 }; | |
| 62 | |
| 63 } // namespace usb | |
| 64 } // namespace device | |
| 65 | |
| 66 #endif // DEVICE_USB_DEVICE_MANAGER_IMPL_H_ | |
| OLD | NEW |