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

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

Issue 2849953003: Use the task scheduler for blocking tasks in the USB service on Linux (Closed)
Patch Set: Remove more passing of the SequencedTaskRunner Created 3 years, 7 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/udev_linux/udev_watcher.cc ('k') | device/usb/usb_device_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 #ifndef DEVICE_USB_USB_DEVICE_ANDROID_H_ 5 #ifndef DEVICE_USB_USB_DEVICE_ANDROID_H_
6 #define DEVICE_USB_USB_DEVICE_ANDROID_H_ 6 #define DEVICE_USB_USB_DEVICE_ANDROID_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "device/usb/usb_device.h" 10 #include "device/usb/usb_device.h"
11 11
12 namespace base {
13 class SequencedTaskRunner;
14 }
15
16 namespace device { 12 namespace device {
17 13
18 class UsbServiceAndroid; 14 class UsbServiceAndroid;
19 15
20 class UsbDeviceAndroid : public UsbDevice { 16 class UsbDeviceAndroid : public UsbDevice {
21 public: 17 public:
22 static scoped_refptr<UsbDeviceAndroid> Create( 18 static scoped_refptr<UsbDeviceAndroid> Create(
23 JNIEnv* env, 19 JNIEnv* env,
24 base::WeakPtr<UsbServiceAndroid> service, 20 base::WeakPtr<UsbServiceAndroid> service,
25 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
26 const base::android::JavaRef<jobject>& usb_device); 21 const base::android::JavaRef<jobject>& usb_device);
27 22
28 // UsbDevice: 23 // UsbDevice:
29 void RequestPermission(const ResultCallback& callback) override; 24 void RequestPermission(const ResultCallback& callback) override;
30 bool permission_granted() const override; 25 bool permission_granted() const override;
31 void Open(const OpenCallback& callback) override; 26 void Open(const OpenCallback& callback) override;
32 27
33 jint device_id() const { return device_id_; } 28 jint device_id() const { return device_id_; }
34 void PermissionGranted(bool granted); 29 void PermissionGranted(bool granted);
35 30
36 private: 31 private:
37 UsbDeviceAndroid( 32 UsbDeviceAndroid(
38 JNIEnv* env, 33 JNIEnv* env,
39 base::WeakPtr<UsbServiceAndroid> service, 34 base::WeakPtr<UsbServiceAndroid> service,
40 uint16_t usb_version, 35 uint16_t usb_version,
41 uint8_t device_class, 36 uint8_t device_class,
42 uint8_t device_subclass, 37 uint8_t device_subclass,
43 uint8_t device_protocol, 38 uint8_t device_protocol,
44 uint16_t vendor_id, 39 uint16_t vendor_id,
45 uint16_t product_id, 40 uint16_t product_id,
46 uint16_t device_version, 41 uint16_t device_version,
47 const base::string16& manufacturer_string, 42 const base::string16& manufacturer_string,
48 const base::string16& product_string, 43 const base::string16& product_string,
49 const base::string16& serial_number, 44 const base::string16& serial_number,
50 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
51 const base::android::JavaRef<jobject>& wrapper); 45 const base::android::JavaRef<jobject>& wrapper);
52 ~UsbDeviceAndroid() override; 46 ~UsbDeviceAndroid() override;
53 47
54 void CallRequestPermissionCallbacks(bool granted); 48 void CallRequestPermissionCallbacks(bool granted);
55 void OnDeviceOpenedToReadDescriptors( 49 void OnDeviceOpenedToReadDescriptors(
56 scoped_refptr<UsbDeviceHandle> device_handle); 50 scoped_refptr<UsbDeviceHandle> device_handle);
57 void OnReadDescriptors(scoped_refptr<UsbDeviceHandle> device_handle, 51 void OnReadDescriptors(scoped_refptr<UsbDeviceHandle> device_handle,
58 std::unique_ptr<UsbDeviceDescriptor> descriptor); 52 std::unique_ptr<UsbDeviceDescriptor> descriptor);
59 void OnReadWebUsbDescriptors( 53 void OnReadWebUsbDescriptors(
60 scoped_refptr<UsbDeviceHandle> device_handle, 54 scoped_refptr<UsbDeviceHandle> device_handle,
61 std::unique_ptr<WebUsbAllowedOrigins> allowed_origins, 55 std::unique_ptr<WebUsbAllowedOrigins> allowed_origins,
62 const GURL& landing_page); 56 const GURL& landing_page);
63 57
64 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
65
66 const jint device_id_; 58 const jint device_id_;
67 bool permission_granted_ = false; 59 bool permission_granted_ = false;
68 std::list<ResultCallback> request_permission_callbacks_; 60 std::list<ResultCallback> request_permission_callbacks_;
69 base::WeakPtr<UsbServiceAndroid> service_; 61 base::WeakPtr<UsbServiceAndroid> service_;
70 62
71 // Java object org.chromium.device.usb.ChromeUsbDevice. 63 // Java object org.chromium.device.usb.ChromeUsbDevice.
72 base::android::ScopedJavaGlobalRef<jobject> j_object_; 64 base::android::ScopedJavaGlobalRef<jobject> j_object_;
73 }; 65 };
74 66
75 } // namespace device 67 } // namespace device
76 68
77 #endif // DEVICE_USB_USB_DEVICE_ANDROID_H_ 69 #endif // DEVICE_USB_USB_DEVICE_ANDROID_H_
OLDNEW
« no previous file with comments | « device/udev_linux/udev_watcher.cc ('k') | device/usb/usb_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698