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" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 class Shell; | 20 class Shell; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 class WebUSBDeviceImpl : public blink::WebUSBDevice { | 25 class WebUSBDeviceImpl : public blink::WebUSBDevice, public mojo::ErrorHandler { |
25 public: | 26 public: |
26 WebUSBDeviceImpl(device::usb::DeviceManagerPtr device_manager, | 27 WebUSBDeviceImpl(device::usb::DeviceManagerPtr device_manager, |
27 const blink::WebUSBDeviceInfo& device_info); | 28 const blink::WebUSBDeviceInfo& device_info); |
28 ~WebUSBDeviceImpl() override; | 29 ~WebUSBDeviceImpl() override; |
29 | 30 |
30 private: | 31 private: |
31 // blink::WebUSBDevice implementation: | 32 // blink::WebUSBDevice implementation: |
32 const blink::WebUSBDeviceInfo& info() const override; | 33 const blink::WebUSBDeviceInfo& info() const override; |
33 void open(blink::WebUSBDeviceOpenCallbacks* callbacks) override; | 34 void open(blink::WebUSBDeviceOpenCallbacks* callbacks) override; |
34 void close(blink::WebUSBDeviceCloseCallbacks* callbacks) override; | 35 void close(blink::WebUSBDeviceCloseCallbacks* callbacks) override; |
(...skipping 19 matching lines...) Expand all Loading... |
54 unsigned int timeout, | 55 unsigned int timeout, |
55 blink::WebUSBDeviceControlTransferCallbacks* callbacks) override; | 56 blink::WebUSBDeviceControlTransferCallbacks* callbacks) override; |
56 void transfer(blink::WebUSBDevice::TransferDirection direction, | 57 void transfer(blink::WebUSBDevice::TransferDirection direction, |
57 uint8_t endpoint_number, | 58 uint8_t endpoint_number, |
58 uint8_t* data, | 59 uint8_t* data, |
59 size_t data_size, | 60 size_t data_size, |
60 unsigned int timeout, | 61 unsigned int timeout, |
61 blink::WebUSBDeviceBulkTransferCallbacks* callbacks) override; | 62 blink::WebUSBDeviceBulkTransferCallbacks* callbacks) override; |
62 void reset(blink::WebUSBDeviceResetCallbacks* callbacks) override; | 63 void reset(blink::WebUSBDeviceResetCallbacks* callbacks) override; |
63 | 64 |
| 65 // mojo::ErrorHandler implementation: |
| 66 void OnConnectionError() override; |
| 67 |
64 device::usb::DeviceManagerPtr device_manager_; | 68 device::usb::DeviceManagerPtr device_manager_; |
65 | 69 |
66 blink::WebUSBDeviceInfo device_info_; | 70 blink::WebUSBDeviceInfo device_info_; |
67 device::usb::DevicePtr device_; | 71 device::usb::DevicePtr device_; |
68 | 72 |
69 base::WeakPtrFactory<WebUSBDeviceImpl> weak_factory_; | 73 base::WeakPtrFactory<WebUSBDeviceImpl> weak_factory_; |
70 | 74 |
71 DISALLOW_COPY_AND_ASSIGN(WebUSBDeviceImpl); | 75 DISALLOW_COPY_AND_ASSIGN(WebUSBDeviceImpl); |
72 }; | 76 }; |
73 | 77 |
74 } // namespace content | 78 } // namespace content |
75 | 79 |
76 #endif // CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ | 80 #endif // CONTENT_RENDERER_USB_WEB_USB_DEVICE_IMPL_H_ |
OLD | NEW |