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

Unified 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, 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_android.h
diff --git a/device/usb/usb_service_android.h b/device/usb/usb_service_android.h
index 9cab43851716cbccbd4b31b58cf8896492ad0d89..cfa0e45a2e2f76349822ac6bb0d1c650b573909b 100644
--- a/device/usb/usb_service_android.h
+++ b/device/usb/usb_service_android.h
@@ -6,12 +6,15 @@
#define DEVICE_USB_USB_SERVICE_ANDROID_H_
#include <string>
+#include <unordered_map>
#include "base/android/scoped_java_ref.h"
#include "device/usb/usb_service.h"
namespace device {
+class UsbDeviceAndroid;
+
// USB service implementation for Android. This is a stub implementation that
// does not return any devices.
class UsbServiceAndroid : public UsbService {
@@ -26,7 +29,21 @@ class UsbServiceAndroid : public UsbService {
scoped_refptr<UsbDevice> GetDevice(const std::string& guid) override;
void GetDevices(const GetDevicesCallback& callback) override;
+ // Methods called by Java.
+ void DeviceAttached(JNIEnv* env,
+ const base::android::JavaRef<jobject>& caller,
+ const base::android::JavaRef<jobject>& usb_device);
+ void DeviceDetached(JNIEnv* env,
+ const base::android::JavaRef<jobject>& caller,
+ jint device_id);
+
private:
+ void AddDevice(scoped_refptr<UsbDeviceAndroid> device);
+
+ std::unordered_map<jint, scoped_refptr<UsbDeviceAndroid>> devices_by_id_;
+ std::unordered_map<std::string, scoped_refptr<UsbDeviceAndroid>>
+ devices_by_guid_;
+
// Java object org.chromium.device.usb.ChromeUsbService.
base::android::ScopedJavaGlobalRef<jobject> j_object_;
};
« 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