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 CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ |
6 #define CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ | 6 #define CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "device/devices_app/usb/public/interfaces/device.mojom.h" | 11 #include "device/devices_app/usb/public/interfaces/device.mojom.h" |
12 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" | 12 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" |
13 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 13 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
14 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDevice.h" | 14 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDevice.h" |
15 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDeviceInfo.h" | 15 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBDeviceInfo.h" |
16 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBError.h" | 16 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBError.h" |
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | |
18 | 17 |
19 namespace mojo { | 18 namespace mojo { |
20 class Shell; | 19 class Shell; |
21 } | 20 } |
22 | 21 |
23 namespace content { | 22 namespace content { |
24 | 23 |
25 class WebUSBDeviceImpl : public blink::WebUSBDevice, public mojo::ErrorHandler { | 24 class WebUSBDeviceImpl : public blink::WebUSBDevice { |
26 public: | 25 public: |
27 WebUSBDeviceImpl(device::usb::DeviceManagerPtr device_manager, | 26 WebUSBDeviceImpl(device::usb::DeviceManagerPtr device_manager, |
28 const blink::WebUSBDeviceInfo& device_info); | 27 const blink::WebUSBDeviceInfo& device_info); |
29 ~WebUSBDeviceImpl() override; | 28 ~WebUSBDeviceImpl() override; |
30 | 29 |
31 private: | 30 private: |
32 // blink::WebUSBDevice implementation: | 31 // blink::WebUSBDevice implementation: |
33 const blink::WebUSBDeviceInfo& info() const override; | 32 const blink::WebUSBDeviceInfo& info() const override; |
34 void open(blink::WebUSBDeviceOpenCallbacks* callbacks) override; | 33 void open(blink::WebUSBDeviceOpenCallbacks* callbacks) override; |
35 void close(blink::WebUSBDeviceCloseCallbacks* callbacks) override; | 34 void close(blink::WebUSBDeviceCloseCallbacks* callbacks) override; |
(...skipping 19 matching lines...) Expand all Loading... |
55 unsigned int timeout, | 54 unsigned int timeout, |
56 blink::WebUSBDeviceControlTransferCallbacks* callbacks) override; | 55 blink::WebUSBDeviceControlTransferCallbacks* callbacks) override; |
57 void transfer(blink::WebUSBDevice::TransferDirection direction, | 56 void transfer(blink::WebUSBDevice::TransferDirection direction, |
58 uint8_t endpoint_number, | 57 uint8_t endpoint_number, |
59 uint8_t* data, | 58 uint8_t* data, |
60 size_t data_size, | 59 size_t data_size, |
61 unsigned int timeout, | 60 unsigned int timeout, |
62 blink::WebUSBDeviceBulkTransferCallbacks* callbacks) override; | 61 blink::WebUSBDeviceBulkTransferCallbacks* callbacks) override; |
63 void reset(blink::WebUSBDeviceResetCallbacks* callbacks) override; | 62 void reset(blink::WebUSBDeviceResetCallbacks* callbacks) override; |
64 | 63 |
65 // mojo::ErrorHandler implementation: | |
66 void OnConnectionError() override; | |
67 | |
68 device::usb::DeviceManagerPtr device_manager_; | 64 device::usb::DeviceManagerPtr device_manager_; |
69 | 65 |
70 blink::WebUSBDeviceInfo device_info_; | 66 blink::WebUSBDeviceInfo device_info_; |
71 device::usb::DevicePtr device_; | 67 device::usb::DevicePtr device_; |
72 | 68 |
73 base::WeakPtrFactory<WebUSBDeviceImpl> weak_factory_; | 69 base::WeakPtrFactory<WebUSBDeviceImpl> weak_factory_; |
74 | 70 |
75 DISALLOW_COPY_AND_ASSIGN(WebUSBDeviceImpl); | 71 DISALLOW_COPY_AND_ASSIGN(WebUSBDeviceImpl); |
76 }; | 72 }; |
77 | 73 |
78 } // namespace content | 74 } // namespace content |
79 | 75 |
80 #endif // CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ | 76 #endif // CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ |
OLD | NEW |