| 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 f2230168bab27d3d71f3bacab42d8ea78c34cc19..4f919f7800f18ecac054341d09f90edb8124fee5 100644
|
| --- a/chrome/browser/extensions/api/usb/usb_api.h
|
| +++ b/chrome/browser/extensions/api/usb/usb_api.h
|
| @@ -10,12 +10,10 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "chrome/browser/extensions/api/api_function.h"
|
| #include "chrome/browser/extensions/api/api_resource_manager.h"
|
| -#include "chrome/browser/usb/usb_device.h"
|
| +#include "chrome/browser/usb/usb_device_handle.h"
|
| #include "chrome/common/extensions/api/usb.h"
|
| #include "net/base/io_buffer.h"
|
|
|
| -class UsbDevice;
|
| -
|
| namespace extensions {
|
|
|
| class UsbDeviceResource;
|
| @@ -46,35 +44,80 @@ class UsbAsyncApiTransferFunction : public UsbAsyncApiFunction {
|
| bool ConvertDirectionSafely(const extensions::api::usb::Direction& input,
|
| UsbEndpointDirection* output);
|
| bool ConvertRequestTypeSafely(const extensions::api::usb::RequestType& input,
|
| - UsbDevice::TransferRequestType* output);
|
| + UsbDeviceHandle::TransferRequestType* output);
|
| bool ConvertRecipientSafely(const extensions::api::usb::Recipient& input,
|
| - UsbDevice::TransferRecipient* output);
|
| + UsbDeviceHandle::TransferRecipient* output);
|
|
|
| - void OnCompleted(UsbTransferStatus status,
|
| - scoped_refptr<net::IOBuffer> data,
|
| + void OnCompleted(UsbTransferStatus status, scoped_refptr<net::IOBuffer> data,
|
| size_t length);
|
| };
|
|
|
| -class UsbFindDevicesFunction : public UsbAsyncApiFunction {
|
| +class UsbGetDevicesFunction : public UsbAsyncApiFunction {
|
| + public:
|
| + DECLARE_EXTENSION_FUNCTION("usb.getDevices", USB_GETDEVICES)
|
| +
|
| + UsbGetDevicesFunction();
|
| +
|
| + static void SetDeviceForTest(UsbDeviceHandle* device);
|
| +
|
| + protected:
|
| + virtual ~UsbGetDevicesFunction();
|
| +
|
| + virtual bool PrePrepare() OVERRIDE;
|
| + virtual bool Prepare() OVERRIDE;
|
| + virtual void AsyncWorkStart() OVERRIDE;
|
| +
|
| + // Called on FILE thread.
|
| + void OnDevicesFound();
|
| + virtual void OnCompleted();
|
| +
|
| + scoped_ptr<base::ListValue> result_;
|
| + std::vector<int> devices_;
|
| + int vendor_id_;
|
| + int product_id_;
|
| + int interface_id_;
|
| + UsbService* service_;
|
| +};
|
| +
|
| +class UsbFindDevicesFunction : public UsbGetDevicesFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("usb.findDevices", USB_FINDDEVICES)
|
|
|
| UsbFindDevicesFunction();
|
|
|
| - static void SetDeviceForTest(UsbDevice* device);
|
| -
|
| protected:
|
| virtual ~UsbFindDevicesFunction();
|
|
|
| virtual bool Prepare() OVERRIDE;
|
| +
|
| + // Called on FILE thread.
|
| + virtual void OnCompleted() OVERRIDE;
|
| +
|
| + // Called on IO thread.
|
| + void OpenDevices();
|
| +
|
| + std::vector<scoped_refptr<UsbDeviceHandle> > handles_;
|
| +};
|
| +
|
| +class UsbOpenDeviceFunction : public UsbAsyncApiFunction {
|
| + public:
|
| + DECLARE_EXTENSION_FUNCTION("usb.openDevice", USB_OPENDEVICE)
|
| +
|
| + UsbOpenDeviceFunction();
|
| +
|
| + protected:
|
| + virtual ~UsbOpenDeviceFunction();
|
| +
|
| + virtual bool PrePrepare() OVERRIDE;
|
| + virtual bool Prepare() OVERRIDE;
|
| virtual void AsyncWorkStart() OVERRIDE;
|
|
|
| private:
|
| - void OnCompleted();
|
| + void OpenDevice();
|
| + void OnCompleted(scoped_refptr<UsbDeviceHandle> handle);
|
|
|
| - scoped_ptr<base::ListValue> result_;
|
| - std::vector<scoped_refptr<UsbDevice> > devices_;
|
| - scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_;
|
| + scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters_;
|
| + UsbService* service_;
|
| };
|
|
|
| class UsbListInterfacesFunction : public UsbAsyncApiFunction {
|
| @@ -98,7 +141,7 @@ class UsbListInterfacesFunction : public UsbAsyncApiFunction {
|
| const UsbSynchronizationType& input,
|
| extensions::api::usb::SynchronizationType* output);
|
| bool ConvertTransferTypeSafely(const UsbTransferType& input,
|
| - extensions::api::usb::TransferType* output);
|
| + extensions::api::usb::TransferType* output);
|
| bool ConvertUsageTypeSafely(const UsbUsageType& input,
|
| extensions::api::usb::UsageType* output);
|
|
|
| @@ -119,9 +162,9 @@ class UsbCloseDeviceFunction : public UsbAsyncApiFunction {
|
| virtual bool Prepare() OVERRIDE;
|
| virtual void AsyncWorkStart() OVERRIDE;
|
|
|
| + private:
|
| void OnCompleted();
|
|
|
| - private:
|
| scoped_ptr<extensions::api::usb::CloseDevice::Params> parameters_;
|
| };
|
|
|
| @@ -209,8 +252,7 @@ class UsbBulkTransferFunction : public UsbAsyncApiTransferFunction {
|
| virtual void AsyncWorkStart() OVERRIDE;
|
|
|
| private:
|
| - scoped_ptr<extensions::api::usb::BulkTransfer::Params>
|
| - parameters_;
|
| + scoped_ptr<extensions::api::usb::BulkTransfer::Params> parameters_;
|
| };
|
|
|
| class UsbInterruptTransferFunction : public UsbAsyncApiTransferFunction {
|
|
|