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

Unified Diff: chrome/browser/extensions/api/usb/usb_api.h

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/usb/usb_api.h
diff --git a/chrome/browser/extensions/api/usb/usb_api.h b/chrome/browser/extensions/api/usb/usb_api.h
index 8f39b5e27eb31d23604c9d44c5ab69d201c4b6fd..14e2540de8f02aee832427ef3b9b82d757f81874 100644
--- a/chrome/browser/extensions/api/usb/usb_api.h
+++ b/chrome/browser/extensions/api/usb/usb_api.h
@@ -64,8 +64,6 @@ class UsbFindDevicesFunction : public UsbAsyncApiFunction {
UsbFindDevicesFunction();
- static void SetDeviceForTest(UsbDevice* device);
-
protected:
virtual ~UsbFindDevicesFunction();
@@ -85,6 +83,51 @@ class UsbFindDevicesFunction : public UsbAsyncApiFunction {
scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_;
};
+class UsbGetDevicesFunction : public UsbAsyncApiFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("usb.getDevices", USB_GETDEVICES)
+
+ UsbGetDevicesFunction();
+
+ static void SetDeviceForTest(UsbDevice* device);
+
+ virtual bool Prepare() OVERRIDE;
+ virtual void AsyncWorkStart() OVERRIDE;
+
+ protected:
+ virtual ~UsbGetDevicesFunction();
+
+ private:
+ void EnumerationCompletedFileThread(
+ scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices);
+
+ scoped_ptr<base::ListValue> result_;
+ scoped_ptr<extensions::api::usb::GetDevices::Params> parameters_;
+};
+
+class UsbOpenDeviceFunction : public UsbAsyncApiFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("usb.openDevice", USB_OPENDEVICE)
+
+ UsbOpenDeviceFunction();
+
+ virtual bool Prepare() OVERRIDE;
+ virtual void AsyncWorkStart() OVERRIDE;
+
+ protected:
+ virtual ~UsbOpenDeviceFunction();
+
+ private:
+ void OpenDeviceOnFile();
+
+ // This should be run on the IO thread.
+ // Create ApiResources and reply.
asargent_no_longer_on_chrome 2013/08/22 21:06:13 Does it actually create a UsbDeviceResource or som
Bei Zhang 2013/08/23 22:52:00 This is not needed since we simplified the threadi
+ void OnCompleted();
+
+ scoped_refptr<UsbDeviceHandle> handle_;
+ scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters_;
+};
+
class UsbListInterfacesFunction : public UsbAsyncApiFunction {
public:
DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES)
« no previous file with comments | « no previous file | chrome/browser/extensions/api/usb/usb_api.cc » ('j') | chrome/browser/extensions/api/usb/usb_api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698