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

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

Issue 2017273002: Support USB device hotplug on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add dependency on //device/usb:java. Created 4 years, 6 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_service_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_SERVICE_ANDROID_H_ 5 #ifndef DEVICE_USB_USB_SERVICE_ANDROID_H_
6 #define DEVICE_USB_USB_SERVICE_ANDROID_H_ 6 #define DEVICE_USB_USB_SERVICE_ANDROID_H_
7 7
8 #include <string> 8 #include <string>
9 #include <unordered_map>
9 10
10 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
11 #include "device/usb/usb_service.h" 12 #include "device/usb/usb_service.h"
12 13
13 namespace device { 14 namespace device {
14 15
16 class UsbDeviceAndroid;
17
15 // USB service implementation for Android. This is a stub implementation that 18 // USB service implementation for Android. This is a stub implementation that
16 // does not return any devices. 19 // does not return any devices.
17 class UsbServiceAndroid : public UsbService { 20 class UsbServiceAndroid : public UsbService {
18 public: 21 public:
19 // Register C++ methods exposed to Java using JNI. 22 // Register C++ methods exposed to Java using JNI.
20 static bool RegisterJNI(JNIEnv* env); 23 static bool RegisterJNI(JNIEnv* env);
21 24
22 UsbServiceAndroid(); 25 UsbServiceAndroid();
23 ~UsbServiceAndroid() override; 26 ~UsbServiceAndroid() override;
24 27
25 // UsbService: 28 // UsbService:
26 scoped_refptr<UsbDevice> GetDevice(const std::string& guid) override; 29 scoped_refptr<UsbDevice> GetDevice(const std::string& guid) override;
27 void GetDevices(const GetDevicesCallback& callback) override; 30 void GetDevices(const GetDevicesCallback& callback) override;
28 31
32 // Methods called by Java.
33 void DeviceAttached(JNIEnv* env,
34 const base::android::JavaRef<jobject>& caller,
35 const base::android::JavaRef<jobject>& usb_device);
36 void DeviceDetached(JNIEnv* env,
37 const base::android::JavaRef<jobject>& caller,
38 jint device_id);
39
29 private: 40 private:
41 void AddDevice(scoped_refptr<UsbDeviceAndroid> device);
42
43 std::unordered_map<jint, scoped_refptr<UsbDeviceAndroid>> devices_by_id_;
44 std::unordered_map<std::string, scoped_refptr<UsbDeviceAndroid>>
45 devices_by_guid_;
46
30 // Java object org.chromium.device.usb.ChromeUsbService. 47 // Java object org.chromium.device.usb.ChromeUsbService.
31 base::android::ScopedJavaGlobalRef<jobject> j_object_; 48 base::android::ScopedJavaGlobalRef<jobject> j_object_;
32 }; 49 };
33 50
34 } // namespace device 51 } // namespace device
35 52
36 #endif // DEVICE_USB_USB_SERVICE_ANDROID_H_ 53 #endif // DEVICE_USB_USB_SERVICE_ANDROID_H_
OLDNEW
« no previous file with comments | « device/usb/usb_device_android.cc ('k') | device/usb/usb_service_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698