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

Side by Side Diff: device/usb/usb_device_handle_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_device_android.cc ('k') | device/usb/usb_endpoint_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 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; 12 using base::android::ScopedJavaLocalRef;
13 13
14 namespace device { 14 namespace device {
15 15
16 // static 16 // static
17 scoped_refptr<UsbDeviceHandleAndroid> UsbDeviceHandleAndroid::Create( 17 scoped_refptr<UsbDeviceHandleAndroid> UsbDeviceHandleAndroid::Create(
18 JNIEnv* env, 18 JNIEnv* env,
19 scoped_refptr<UsbDevice> device, 19 scoped_refptr<UsbDevice> device,
20 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 20 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
21 const base::android::JavaRef<jobject>& usb_connection) { 21 const base::android::JavaRef<jobject>& usb_connection) {
22 ScopedJavaLocalRef<jobject> wrapper = 22 ScopedJavaLocalRef<jobject> wrapper =
23 Java_ChromeUsbConnection_create(env, usb_connection.obj()); 23 Java_ChromeUsbConnection_create(env, usb_connection);
24 base::ScopedFD fd( 24 base::ScopedFD fd(Java_ChromeUsbConnection_getFileDescriptor(env, wrapper));
25 Java_ChromeUsbConnection_getFileDescriptor(env, wrapper.obj()));
26 return make_scoped_refptr(new UsbDeviceHandleAndroid( 25 return make_scoped_refptr(new UsbDeviceHandleAndroid(
27 device, std::move(fd), blocking_task_runner, wrapper)); 26 device, std::move(fd), blocking_task_runner, wrapper));
28 } 27 }
29 28
30 UsbDeviceHandleAndroid::UsbDeviceHandleAndroid( 29 UsbDeviceHandleAndroid::UsbDeviceHandleAndroid(
31 scoped_refptr<UsbDevice> device, 30 scoped_refptr<UsbDevice> device,
32 base::ScopedFD fd, 31 base::ScopedFD fd,
33 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 32 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
34 const base::android::JavaRef<jobject>& wrapper) 33 const base::android::JavaRef<jobject>& wrapper)
35 : UsbDeviceHandleUsbfs(device, std::move(fd), blocking_task_runner), 34 : UsbDeviceHandleUsbfs(device, std::move(fd), blocking_task_runner),
36 j_object_(wrapper) {} 35 j_object_(wrapper) {}
37 36
38 UsbDeviceHandleAndroid::~UsbDeviceHandleAndroid() {} 37 UsbDeviceHandleAndroid::~UsbDeviceHandleAndroid() {}
39 38
40 void UsbDeviceHandleAndroid::CloseBlocking() { 39 void UsbDeviceHandleAndroid::CloseBlocking() {
41 ReleaseFileDescriptor(); 40 ReleaseFileDescriptor();
42 task_runner()->PostTask( 41 task_runner()->PostTask(
43 FROM_HERE, base::Bind(&UsbDeviceHandleAndroid::CloseConnection, this)); 42 FROM_HERE, base::Bind(&UsbDeviceHandleAndroid::CloseConnection, this));
44 } 43 }
45 44
46 void UsbDeviceHandleAndroid::CloseConnection() { 45 void UsbDeviceHandleAndroid::CloseConnection() {
47 JNIEnv* env = base::android::AttachCurrentThread(); 46 JNIEnv* env = base::android::AttachCurrentThread();
48 Java_ChromeUsbConnection_close(env, j_object_.obj()); 47 Java_ChromeUsbConnection_close(env, j_object_);
49 j_object_.Reset(); 48 j_object_.Reset();
50 } 49 }
51 50
52 } // namespace device 51 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device_android.cc ('k') | device/usb/usb_endpoint_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698