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 #include "device/usb/usb_device_handle_android.h" | 5 #include "device/usb/usb_device_handle_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "device/usb/usb_device.h" | 9 #include "device/usb/usb_device.h" |
10 #include "jni/ChromeUsbConnection_jni.h" | 10 #include "jni/ChromeUsbConnection_jni.h" |
11 | 11 |
| 12 using base::android::ScopedJavaLocalRef; |
| 13 |
12 namespace device { | 14 namespace device { |
13 | 15 |
14 // static | 16 // static |
15 scoped_refptr<UsbDeviceHandleAndroid> UsbDeviceHandleAndroid::Create( | 17 scoped_refptr<UsbDeviceHandleAndroid> UsbDeviceHandleAndroid::Create( |
16 JNIEnv* env, | 18 JNIEnv* env, |
17 scoped_refptr<UsbDevice> device, | 19 scoped_refptr<UsbDevice> device, |
18 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 20 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
19 const base::android::JavaRef<jobject>& usb_connection) { | 21 const base::android::JavaRef<jobject>& usb_connection) { |
20 ScopedJavaLocalRef<jobject> wrapper = | 22 ScopedJavaLocalRef<jobject> wrapper = |
21 Java_ChromeUsbConnection_create(env, usb_connection.obj()); | 23 Java_ChromeUsbConnection_create(env, usb_connection.obj()); |
(...skipping 19 matching lines...) Expand all Loading... |
41 FROM_HERE, base::Bind(&UsbDeviceHandleAndroid::CloseConnection, this)); | 43 FROM_HERE, base::Bind(&UsbDeviceHandleAndroid::CloseConnection, this)); |
42 } | 44 } |
43 | 45 |
44 void UsbDeviceHandleAndroid::CloseConnection() { | 46 void UsbDeviceHandleAndroid::CloseConnection() { |
45 JNIEnv* env = base::android::AttachCurrentThread(); | 47 JNIEnv* env = base::android::AttachCurrentThread(); |
46 Java_ChromeUsbConnection_close(env, j_object_.obj()); | 48 Java_ChromeUsbConnection_close(env, j_object_.obj()); |
47 j_object_.Reset(); | 49 j_object_.Reset(); |
48 } | 50 } |
49 | 51 |
50 } // namespace device | 52 } // namespace device |
OLD | NEW |