OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_USB_DEVICE_HANDLE_ANDROID_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_ |
6 #define DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_ | 6 #define DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_ |
7 | 7 |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "device/usb/usb_device_handle_usbfs.h" | 9 #include "device/usb/usb_device_handle_usbfs.h" |
10 | 10 |
11 namespace device { | 11 namespace device { |
12 | 12 |
13 class UsbDevice; | 13 class UsbDevice; |
14 | 14 |
15 // Extends UsbDeviceHandleUsbfs with support for managing a device connection | 15 // Extends UsbDeviceHandleUsbfs with support for managing a device connection |
16 // through an instance of android.hardware.usb.UsbDeviceConnection. | 16 // through an instance of android.hardware.usb.UsbDeviceConnection. |
17 class UsbDeviceHandleAndroid : public UsbDeviceHandleUsbfs { | 17 class UsbDeviceHandleAndroid : public UsbDeviceHandleUsbfs { |
18 public: | 18 public: |
19 // Register C++ methods exposed to Java using JNI. | |
20 static bool RegisterJNI(JNIEnv* env); | |
21 | |
22 static scoped_refptr<UsbDeviceHandleAndroid> Create( | 19 static scoped_refptr<UsbDeviceHandleAndroid> Create( |
23 JNIEnv* env, | 20 JNIEnv* env, |
24 scoped_refptr<UsbDevice> device, | 21 scoped_refptr<UsbDevice> device, |
25 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 22 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
26 const base::android::JavaRef<jobject>& usb_connection); | 23 const base::android::JavaRef<jobject>& usb_connection); |
27 | 24 |
28 private: | 25 private: |
29 // |wrapper| is an instance of org.chromium.device.usb.ChromeUsbConnection. | 26 // |wrapper| is an instance of org.chromium.device.usb.ChromeUsbConnection. |
30 UsbDeviceHandleAndroid( | 27 UsbDeviceHandleAndroid( |
31 scoped_refptr<UsbDevice> device, | 28 scoped_refptr<UsbDevice> device, |
32 base::ScopedFD fd, | 29 base::ScopedFD fd, |
33 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 30 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
34 const base::android::JavaRef<jobject>& wrapper); | 31 const base::android::JavaRef<jobject>& wrapper); |
35 ~UsbDeviceHandleAndroid() override; | 32 ~UsbDeviceHandleAndroid() override; |
36 | 33 |
37 // UsbDeviceHandleUsbfs: | 34 // UsbDeviceHandleUsbfs: |
38 void CloseBlocking() override; | 35 void CloseBlocking() override; |
39 | 36 |
40 void CloseConnection(); | 37 void CloseConnection(); |
41 | 38 |
42 // Java object org.chromium.device.usb.ChromeUsbConnection. | 39 // Java object org.chromium.device.usb.ChromeUsbConnection. |
43 base::android::ScopedJavaGlobalRef<jobject> j_object_; | 40 base::android::ScopedJavaGlobalRef<jobject> j_object_; |
44 }; | 41 }; |
45 | 42 |
46 } // namespace device | 43 } // namespace device |
47 | 44 |
48 #endif // DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_ | 45 #endif // DEVICE_USB_USB_DEVICE_HANDLE_ANDROID_H_ |
OLD | NEW |