Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Side by Side Diff: device/usb/usb_device_android.cc

Issue 2237943002: Remove now-unnecessary .obj() in Java method calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch-context
Patch Set: Rebase *again* :( Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/usb_configuration_android.cc ('k') | device/usb/usb_device_handle_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_device_android.h" 5 #include "device/usb/usb_device_android.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace device { 24 namespace device {
25 25
26 // static 26 // static
27 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create( 27 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create(
28 JNIEnv* env, 28 JNIEnv* env,
29 base::WeakPtr<UsbServiceAndroid> service, 29 base::WeakPtr<UsbServiceAndroid> service,
30 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 30 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
31 const JavaRef<jobject>& usb_device) { 31 const JavaRef<jobject>& usb_device) {
32 ScopedJavaLocalRef<jobject> wrapper = 32 ScopedJavaLocalRef<jobject> wrapper =
33 Java_ChromeUsbDevice_create(env, usb_device.obj()); 33 Java_ChromeUsbDevice_create(env, usb_device);
34 uint16_t device_version = 0; 34 uint16_t device_version = 0;
35 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23) 35 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23)
36 device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper.obj()); 36 device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper);
37 base::string16 manufacturer_string, product_string, serial_number; 37 base::string16 manufacturer_string, product_string, serial_number;
38 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { 38 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) {
39 manufacturer_string = ConvertJavaStringToUTF16( 39 manufacturer_string = ConvertJavaStringToUTF16(
40 env, Java_ChromeUsbDevice_getManufacturerName(env, wrapper.obj())); 40 env, Java_ChromeUsbDevice_getManufacturerName(env, wrapper));
41 product_string = ConvertJavaStringToUTF16( 41 product_string = ConvertJavaStringToUTF16(
42 env, Java_ChromeUsbDevice_getProductName(env, wrapper.obj())); 42 env, Java_ChromeUsbDevice_getProductName(env, wrapper));
43 serial_number = ConvertJavaStringToUTF16( 43 serial_number = ConvertJavaStringToUTF16(
44 env, Java_ChromeUsbDevice_getSerialNumber(env, wrapper.obj())); 44 env, Java_ChromeUsbDevice_getSerialNumber(env, wrapper));
45 } 45 }
46 return make_scoped_refptr(new UsbDeviceAndroid( 46 return make_scoped_refptr(new UsbDeviceAndroid(
47 env, service, 47 env, service,
48 0x0200, // USB protocol version, not provided by the Android API. 48 0x0200, // USB protocol version, not provided by the Android API.
49 Java_ChromeUsbDevice_getDeviceClass(env, wrapper.obj()), 49 Java_ChromeUsbDevice_getDeviceClass(env, wrapper),
50 Java_ChromeUsbDevice_getDeviceSubclass(env, wrapper.obj()), 50 Java_ChromeUsbDevice_getDeviceSubclass(env, wrapper),
51 Java_ChromeUsbDevice_getDeviceProtocol(env, wrapper.obj()), 51 Java_ChromeUsbDevice_getDeviceProtocol(env, wrapper),
52 Java_ChromeUsbDevice_getVendorId(env, wrapper.obj()), 52 Java_ChromeUsbDevice_getVendorId(env, wrapper),
53 Java_ChromeUsbDevice_getProductId(env, wrapper.obj()), device_version, 53 Java_ChromeUsbDevice_getProductId(env, wrapper), device_version,
54 manufacturer_string, product_string, serial_number, blocking_task_runner, 54 manufacturer_string, product_string, serial_number, blocking_task_runner,
55 wrapper)); 55 wrapper));
56 } 56 }
57 57
58 void UsbDeviceAndroid::RequestPermission(const ResultCallback& callback) { 58 void UsbDeviceAndroid::RequestPermission(const ResultCallback& callback) {
59 if (!permission_granted_ && service_) { 59 if (!permission_granted_ && service_) {
60 request_permission_callbacks_.push_back(callback); 60 request_permission_callbacks_.push_back(callback);
61 service_->RequestDevicePermission(j_object_, device_id_); 61 service_->RequestDevicePermission(j_object_, device_id_);
62 } else { 62 } else {
63 base::ThreadTaskRunnerHandle::Get()->PostTask( 63 base::ThreadTaskRunnerHandle::Get()->PostTask(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 device_class, 104 device_class,
105 device_subclass, 105 device_subclass,
106 device_protocol, 106 device_protocol,
107 vendor_id, 107 vendor_id,
108 product_id, 108 product_id,
109 device_version, 109 device_version,
110 manufacturer_string, 110 manufacturer_string,
111 product_string, 111 product_string,
112 serial_number), 112 serial_number),
113 blocking_task_runner_(blocking_task_runner), 113 blocking_task_runner_(blocking_task_runner),
114 device_id_(Java_ChromeUsbDevice_getDeviceId(env, wrapper.obj())), 114 device_id_(Java_ChromeUsbDevice_getDeviceId(env, wrapper)),
115 service_(service), 115 service_(service),
116 j_object_(wrapper) { 116 j_object_(wrapper) {
117 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) { 117 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 21) {
118 ScopedJavaLocalRef<jobjectArray> configurations = 118 ScopedJavaLocalRef<jobjectArray> configurations =
119 Java_ChromeUsbDevice_getConfigurations(env, j_object_.obj()); 119 Java_ChromeUsbDevice_getConfigurations(env, j_object_);
120 jsize count = env->GetArrayLength(configurations.obj()); 120 jsize count = env->GetArrayLength(configurations.obj());
121 configurations_.reserve(count); 121 configurations_.reserve(count);
122 for (jsize i = 0; i < count; ++i) { 122 for (jsize i = 0; i < count; ++i) {
123 ScopedJavaLocalRef<jobject> config( 123 ScopedJavaLocalRef<jobject> config(
124 env, env->GetObjectArrayElement(configurations.obj(), i)); 124 env, env->GetObjectArrayElement(configurations.obj(), i));
125 configurations_.push_back(UsbConfigurationAndroid::Convert(env, config)); 125 configurations_.push_back(UsbConfigurationAndroid::Convert(env, config));
126 } 126 }
127 } else { 127 } else {
128 // Pre-lollipop only the first configuration was supported. Build a basic 128 // Pre-lollipop only the first configuration was supported. Build a basic
129 // configuration out of the available interfaces. 129 // configuration out of the available interfaces.
130 UsbConfigDescriptor config(1, // Configuration value, reasonable guess. 130 UsbConfigDescriptor config(1, // Configuration value, reasonable guess.
131 false, // Self powered, arbitrary default. 131 false, // Self powered, arbitrary default.
132 false, // Remote wakeup, rbitrary default. 132 false, // Remote wakeup, rbitrary default.
133 0); // Maximum power, aitrary default. 133 0); // Maximum power, aitrary default.
134 134
135 ScopedJavaLocalRef<jobjectArray> interfaces = 135 ScopedJavaLocalRef<jobjectArray> interfaces =
136 Java_ChromeUsbDevice_getInterfaces(env, wrapper.obj()); 136 Java_ChromeUsbDevice_getInterfaces(env, wrapper);
137 jsize count = env->GetArrayLength(interfaces.obj()); 137 jsize count = env->GetArrayLength(interfaces.obj());
138 config.interfaces.reserve(count); 138 config.interfaces.reserve(count);
139 for (jsize i = 0; i < count; ++i) { 139 for (jsize i = 0; i < count; ++i) {
140 ScopedJavaLocalRef<jobject> interface( 140 ScopedJavaLocalRef<jobject> interface(
141 env, env->GetObjectArrayElement(interfaces.obj(), i)); 141 env, env->GetObjectArrayElement(interfaces.obj(), i));
142 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface)); 142 config.interfaces.push_back(UsbInterfaceAndroid::Convert(env, interface));
143 } 143 }
144 configurations_.push_back(config); 144 configurations_.push_back(config);
145 } 145 }
146 } 146 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (allowed_origins) 203 if (allowed_origins)
204 webusb_allowed_origins_ = std::move(allowed_origins); 204 webusb_allowed_origins_ = std::move(allowed_origins);
205 if (landing_page.is_valid()) 205 if (landing_page.is_valid())
206 webusb_landing_page_ = landing_page; 206 webusb_landing_page_ = landing_page;
207 207
208 device_handle->Close(); 208 device_handle->Close();
209 CallRequestPermissionCallbacks(true); 209 CallRequestPermissionCallbacks(true);
210 } 210 }
211 211
212 } // namespace device 212 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_configuration_android.cc ('k') | device/usb/usb_device_handle_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698