| 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 #include "device/usb/usb_endpoint_android.h" | 5 #include "device/usb/usb_endpoint_android.h" |
| 6 | 6 |
| 7 #include "jni/ChromeUsbEndpoint_jni.h" | 7 #include "jni/ChromeUsbEndpoint_jni.h" |
| 8 | 8 |
| 9 namespace device { | 9 namespace device { |
| 10 | 10 |
| 11 // static | 11 // static |
| 12 bool UsbEndpointAndroid::RegisterJNI(JNIEnv* env) { | 12 bool UsbEndpointAndroid::RegisterJNI(JNIEnv* env) { |
| 13 return RegisterNativesImpl(env); // Generated in ChromeUsbEndpoint_jni.h | 13 return RegisterNativesImpl(env); // Generated in ChromeUsbEndpoint_jni.h |
| 14 } | 14 } |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 UsbEndpointDescriptor UsbEndpointAndroid::Convert( | 17 UsbEndpointDescriptor UsbEndpointAndroid::Convert( |
| 18 JNIEnv* env, | 18 JNIEnv* env, |
| 19 const base::android::JavaRef<jobject>& usb_endpoint) { | 19 const base::android::JavaRef<jobject>& usb_endpoint) { |
| 20 base::android::ScopedJavaLocalRef<jobject> wrapper = | 20 base::android::ScopedJavaLocalRef<jobject> wrapper = |
| 21 Java_ChromeUsbEndpoint_create(env, usb_endpoint.obj()); | 21 Java_ChromeUsbEndpoint_create(env, usb_endpoint.obj()); |
| 22 | 22 |
| 23 UsbEndpointDescriptor endpoint; | |
| 24 endpoint.address = Java_ChromeUsbEndpoint_getAddress(env, wrapper.obj()); | |
| 25 endpoint.direction = static_cast<UsbEndpointDirection>( | |
| 26 Java_ChromeUsbEndpoint_getDirection(env, wrapper.obj())); | |
| 27 endpoint.maximum_packet_size = | |
| 28 Java_ChromeUsbEndpoint_getMaxPacketSize(env, wrapper.obj()); | |
| 29 jint attributes = Java_ChromeUsbEndpoint_getAttributes(env, wrapper.obj()); | 23 jint attributes = Java_ChromeUsbEndpoint_getAttributes(env, wrapper.obj()); |
| 30 endpoint.synchronization_type = | 24 UsbEndpointDescriptor endpoint( |
| 31 static_cast<UsbSynchronizationType>((attributes >> 2) & 3); | 25 Java_ChromeUsbEndpoint_getAddress(env, wrapper.obj()), |
| 32 endpoint.usage_type = static_cast<UsbUsageType>((attributes >> 4) & 3); | 26 static_cast<UsbEndpointDirection>( |
| 33 endpoint.transfer_type = static_cast<UsbTransferType>( | 27 Java_ChromeUsbEndpoint_getDirection(env, wrapper.obj())), |
| 34 Java_ChromeUsbEndpoint_getType(env, wrapper.obj())); | 28 Java_ChromeUsbEndpoint_getMaxPacketSize(env, wrapper.obj()), |
| 35 endpoint.polling_interval = | 29 static_cast<UsbSynchronizationType>((attributes >> 2) & 3), |
| 36 Java_ChromeUsbEndpoint_getInterval(env, wrapper.obj()); | 30 static_cast<UsbTransferType>( |
| 31 Java_ChromeUsbEndpoint_getType(env, wrapper.obj())), |
| 32 static_cast<UsbUsageType>((attributes >> 4) & 3), |
| 33 Java_ChromeUsbEndpoint_getInterval(env, wrapper.obj())); |
| 37 | 34 |
| 38 return endpoint; | 35 return endpoint; |
| 39 } | 36 } |
| 40 | 37 |
| 41 } // namespace device | 38 } // namespace device |
| OLD | NEW |