| 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_MOJO_DEVICE_IMPL_H_ | 5 #ifndef DEVICE_USB_MOJO_DEVICE_IMPL_H_ |
| 6 #define DEVICE_USB_MOJO_DEVICE_IMPL_H_ | 6 #define DEVICE_USB_MOJO_DEVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
| 16 #include "device/usb/mojo/permission_provider.h" | 16 #include "device/usb/mojo/permission_provider.h" |
| 17 #include "device/usb/public/interfaces/device.mojom.h" | 17 #include "device/usb/public/interfaces/device.mojom.h" |
| 18 #include "device/usb/usb_device.h" | 18 #include "device/usb/usb_device.h" |
| 19 #include "device/usb/usb_device_handle.h" | 19 #include "device/usb/usb_device_handle.h" |
| 20 #include "mojo/public/cpp/bindings/binding.h" |
| 20 #include "mojo/public/cpp/bindings/interface_request.h" | 21 #include "mojo/public/cpp/bindings/interface_request.h" |
| 21 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class IOBuffer; | 24 class IOBuffer; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace device { | 27 namespace device { |
| 28 namespace usb { | 28 namespace usb { |
| 29 | 29 |
| 30 class PermissionProvider; | 30 class PermissionProvider; |
| 31 | 31 |
| 32 // Implementation of the public Device interface. Instances of this class are | 32 // Implementation of the public Device interface. Instances of this class are |
| 33 // constructed by DeviceManagerImpl and are strongly bound to their MessagePipe | 33 // constructed by DeviceManagerImpl and are strongly bound to their MessagePipe |
| 34 // lifetime. | 34 // lifetime. |
| 35 class DeviceImpl : public Device, public device::UsbDevice::Observer { | 35 class DeviceImpl : public Device, public device::UsbDevice::Observer { |
| 36 public: | 36 public: |
| 37 DeviceImpl(scoped_refptr<UsbDevice> device, | 37 DeviceImpl(scoped_refptr<UsbDevice> device, |
| 38 DeviceInfoPtr device_info, | 38 DeviceInfoPtr device_info, |
| 39 base::WeakPtr<PermissionProvider> permission_provider, | 39 base::WeakPtr<PermissionProvider> permission_provider, |
| 40 mojo::InterfaceRequest<Device> request); | 40 DeviceRequest request); |
| 41 ~DeviceImpl() override; | 41 ~DeviceImpl() override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // Closes the device if it's open. This will always set |device_handle_| to | 44 // Closes the device if it's open. This will always set |device_handle_| to |
| 45 // null. | 45 // null. |
| 46 void CloseHandle(); | 46 void CloseHandle(); |
| 47 | 47 |
| 48 // Checks interface permissions for control transfers. | 48 // Checks interface permissions for control transfers. |
| 49 bool HasControlTransferPermission(ControlTransferRecipient recipient, | 49 bool HasControlTransferPermission(ControlTransferRecipient recipient, |
| 50 uint16_t index); | 50 uint16_t index); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 const scoped_refptr<UsbDevice> device_; | 104 const scoped_refptr<UsbDevice> device_; |
| 105 const DeviceInfoPtr device_info_; | 105 const DeviceInfoPtr device_info_; |
| 106 base::WeakPtr<PermissionProvider> permission_provider_; | 106 base::WeakPtr<PermissionProvider> permission_provider_; |
| 107 ScopedObserver<device::UsbDevice, device::UsbDevice::Observer> observer_; | 107 ScopedObserver<device::UsbDevice, device::UsbDevice::Observer> observer_; |
| 108 | 108 |
| 109 // The device handle. Will be null before the device is opened and after it | 109 // The device handle. Will be null before the device is opened and after it |
| 110 // has been closed. | 110 // has been closed. |
| 111 scoped_refptr<UsbDeviceHandle> device_handle_; | 111 scoped_refptr<UsbDeviceHandle> device_handle_; |
| 112 | 112 |
| 113 mojo::StrongBinding<Device> binding_; | 113 mojo::Binding<Device> binding_; |
| 114 base::WeakPtrFactory<DeviceImpl> weak_factory_; | 114 base::WeakPtrFactory<DeviceImpl> weak_factory_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(DeviceImpl); | 116 DISALLOW_COPY_AND_ASSIGN(DeviceImpl); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace usb | 119 } // namespace usb |
| 120 } // namespace device | 120 } // namespace device |
| 121 | 121 |
| 122 #endif // DEVICE_USB_MOJO_DEVICE_IMPL_H_ | 122 #endif // DEVICE_USB_MOJO_DEVICE_IMPL_H_ |
| OLD | NEW |