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 CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_
6 #define CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "device/devices_app/usb/public/interfaces/device.mojom.h"
12 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h"
13 #include "mojo/application/public/interfaces/service_provider.mojom.h"
14 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDevice.h"
15 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDeviceInfo.h"
16 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBError.h"
24 class WebUSBDeviceImpl
: public blink::WebUSBDevice
{
26 WebUSBDeviceImpl(device::usb::DevicePtr device
,
27 const blink::WebUSBDeviceInfo
& device_info
);
28 ~WebUSBDeviceImpl() override
;
31 // blink::WebUSBDevice implementation:
32 const blink::WebUSBDeviceInfo
& info() const override
;
33 void open(blink::WebUSBDeviceOpenCallbacks
* callbacks
) override
;
34 void close(blink::WebUSBDeviceCloseCallbacks
* callbacks
) override
;
35 void setConfiguration(
36 uint8_t configuration_value
,
37 blink::WebUSBDeviceSetConfigurationCallbacks
* callbacks
) override
;
39 uint8_t interface_number
,
40 blink::WebUSBDeviceClaimInterfaceCallbacks
* callbacks
) override
;
41 void releaseInterface(
42 uint8_t interface_number
,
43 blink::WebUSBDeviceReleaseInterfaceCallbacks
* callbacks
) override
;
44 void setInterface(uint8_t interface_number
,
45 uint8_t alternate_setting
,
46 blink::WebUSBDeviceSetInterfaceAlternateSettingCallbacks
*
48 void clearHalt(uint8_t endpoint_number
,
49 blink::WebUSBDeviceClearHaltCallbacks
* callbacks
) override
;
51 const blink::WebUSBDevice::ControlTransferParameters
& parameters
,
55 blink::WebUSBDeviceControlTransferCallbacks
* callbacks
) override
;
56 void transfer(blink::WebUSBDevice::TransferDirection direction
,
57 uint8_t endpoint_number
,
61 blink::WebUSBDeviceBulkTransferCallbacks
* callbacks
) override
;
62 void reset(blink::WebUSBDeviceResetCallbacks
* callbacks
) override
;
64 device::usb::DevicePtr device_
;
65 blink::WebUSBDeviceInfo device_info_
;
67 base::WeakPtrFactory
<WebUSBDeviceImpl
> weak_factory_
;
69 DISALLOW_COPY_AND_ASSIGN(WebUSBDeviceImpl
);
72 } // namespace content
74 #endif // CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_