Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / usb / web_usb_device_impl.h
blob172817a3479cd1b90682871ec1f16f88632a61ce
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"
18 namespace mojo {
19 class Shell;
22 namespace content {
24 class WebUSBDeviceImpl : public blink::WebUSBDevice {
25 public:
26 WebUSBDeviceImpl(device::usb::DevicePtr device,
27 const blink::WebUSBDeviceInfo& device_info);
28 ~WebUSBDeviceImpl() override;
30 private:
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;
38 void claimInterface(
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*
47 callbacks) override;
48 void clearHalt(uint8_t endpoint_number,
49 blink::WebUSBDeviceClearHaltCallbacks* callbacks) override;
50 void controlTransfer(
51 const blink::WebUSBDevice::ControlTransferParameters& parameters,
52 uint8_t* data,
53 size_t data_size,
54 unsigned int timeout,
55 blink::WebUSBDeviceControlTransferCallbacks* callbacks) override;
56 void transfer(blink::WebUSBDevice::TransferDirection direction,
57 uint8_t endpoint_number,
58 uint8_t* data,
59 size_t data_size,
60 unsigned int timeout,
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_