Commit a8eaa189 authored by zvorygin@chromium.org's avatar zvorygin@chromium.org

Extracted UsbConfigDescriptor, UsbInterfaceDescriptor and helper classes

as interfaces.

BUG=367094
R=rockot@chromium.org

Review URL: https://codereview.chromium.org/270323003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269767 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a4c78e0
...@@ -27,8 +27,9 @@ ...@@ -27,8 +27,9 @@
'usb_service/usb_device.h', 'usb_service/usb_device.h',
'usb_service/usb_device_handle.cc', 'usb_service/usb_device_handle.cc',
'usb_service/usb_device_handle.h', 'usb_service/usb_device_handle.h',
'usb_service/usb_interface.cc',
'usb_service/usb_interface.h', 'usb_service/usb_interface.h',
'usb_service/usb_interface_impl.cc',
'usb_service/usb_interface_impl.h',
'usb_service/usb_service.h', 'usb_service/usb_service.h',
'usb_service/usb_service_impl.cc', 'usb_service/usb_service_impl.cc',
], ],
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "components/usb_service/usb_context.h" #include "components/usb_service/usb_context.h"
#include "components/usb_service/usb_device_handle.h" #include "components/usb_service/usb_device_handle.h"
#include "components/usb_service/usb_interface_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "third_party/libusb/src/libusb/libusb.h" #include "third_party/libusb/src/libusb/libusb.h"
...@@ -126,7 +127,7 @@ scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() { ...@@ -126,7 +127,7 @@ scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() {
const int list_result = const int list_result =
libusb_get_active_config_descriptor(platform_device_, &platform_config); libusb_get_active_config_descriptor(platform_device_, &platform_config);
if (list_result == 0) if (list_result == 0)
return new UsbConfigDescriptor(platform_config); return new UsbConfigDescriptorImpl(platform_config);
return NULL; return NULL;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/usb_service/usb_device.h" #include "components/usb_service/usb_device.h"
struct libusb_device; struct libusb_device;
struct libusb_config_descriptor;
namespace usb_service { namespace usb_service {
...@@ -20,6 +21,7 @@ class UsbDeviceHandle; ...@@ -20,6 +21,7 @@ class UsbDeviceHandle;
class UsbContext; class UsbContext;
typedef libusb_device* PlatformUsbDevice; typedef libusb_device* PlatformUsbDevice;
typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
class UsbDeviceImpl : public UsbDevice { class UsbDeviceImpl : public UsbDevice {
public: public:
......
...@@ -8,18 +8,8 @@ ...@@ -8,18 +8,8 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "components/usb_service/usb_service_export.h" #include "components/usb_service/usb_service_export.h"
struct libusb_config_descriptor;
struct libusb_endpoint_descriptor;
struct libusb_interface;
struct libusb_interface_descriptor;
namespace usb_service { namespace usb_service {
typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor;
typedef const libusb_interface* PlatformUsbInterface;
typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor;
enum UsbTransferType { enum UsbTransferType {
USB_TRANSFER_CONTROL = 0, USB_TRANSFER_CONTROL = 0,
USB_TRANSFER_ISOCHRONOUS, USB_TRANSFER_ISOCHRONOUS,
...@@ -45,32 +35,22 @@ enum UsbUsageType { ...@@ -45,32 +35,22 @@ enum UsbUsageType {
USB_USAGE_EXPLICIT_FEEDBACK USB_USAGE_EXPLICIT_FEEDBACK
}; };
class UsbDevice;
class UsbConfigDescriptor;
class UsbInterfaceDescriptor;
class UsbInterfaceAltSettingDescriptor;
class USB_SERVICE_EXPORT UsbEndpointDescriptor class USB_SERVICE_EXPORT UsbEndpointDescriptor
: public base::RefCounted<const UsbEndpointDescriptor> { : public base::RefCounted<const UsbEndpointDescriptor> {
public: public:
int GetAddress() const; virtual int GetAddress() const = 0;
UsbEndpointDirection GetDirection() const; virtual UsbEndpointDirection GetDirection() const = 0;
int GetMaximumPacketSize() const; virtual int GetMaximumPacketSize() const = 0;
UsbSynchronizationType GetSynchronizationType() const; virtual UsbSynchronizationType GetSynchronizationType() const = 0;
UsbTransferType GetTransferType() const; virtual UsbTransferType GetTransferType() const = 0;
UsbUsageType GetUsageType() const; virtual UsbUsageType GetUsageType() const = 0;
int GetPollingInterval() const; virtual int GetPollingInterval() const = 0;
private:
friend class base::RefCounted<const UsbEndpointDescriptor>;
friend class UsbInterfaceAltSettingDescriptor;
UsbEndpointDescriptor(scoped_refptr<const UsbConfigDescriptor> config, protected:
PlatformUsbEndpointDescriptor descriptor); friend class base::RefCounted<const UsbEndpointDescriptor>;
~UsbEndpointDescriptor();
scoped_refptr<const UsbConfigDescriptor> config_; UsbEndpointDescriptor() {};
PlatformUsbEndpointDescriptor descriptor_; virtual ~UsbEndpointDescriptor() {};
DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor); DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor);
}; };
...@@ -78,26 +58,21 @@ class USB_SERVICE_EXPORT UsbEndpointDescriptor ...@@ -78,26 +58,21 @@ class USB_SERVICE_EXPORT UsbEndpointDescriptor
class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor
: public base::RefCounted<const UsbInterfaceAltSettingDescriptor> { : public base::RefCounted<const UsbInterfaceAltSettingDescriptor> {
public: public:
size_t GetNumEndpoints() const; virtual size_t GetNumEndpoints() const = 0;
scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(size_t index) const; virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(
size_t index) const = 0;
int GetInterfaceNumber() const; virtual int GetInterfaceNumber() const = 0;
int GetAlternateSetting() const; virtual int GetAlternateSetting() const = 0;
int GetInterfaceClass() const; virtual int GetInterfaceClass() const = 0;
int GetInterfaceSubclass() const; virtual int GetInterfaceSubclass() const = 0;
int GetInterfaceProtocol() const; virtual int GetInterfaceProtocol() const = 0;
private: protected:
friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>; friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>;
friend class UsbInterfaceDescriptor;
UsbInterfaceAltSettingDescriptor(
scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterfaceDescriptor descriptor);
~UsbInterfaceAltSettingDescriptor();
scoped_refptr<const UsbConfigDescriptor> config_; UsbInterfaceAltSettingDescriptor() {};
PlatformUsbInterfaceDescriptor descriptor_; virtual ~UsbInterfaceAltSettingDescriptor() {};
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor); DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor);
}; };
...@@ -105,20 +80,15 @@ class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor ...@@ -105,20 +80,15 @@ class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor
class USB_SERVICE_EXPORT UsbInterfaceDescriptor class USB_SERVICE_EXPORT UsbInterfaceDescriptor
: public base::RefCounted<const UsbInterfaceDescriptor> { : public base::RefCounted<const UsbInterfaceDescriptor> {
public: public:
size_t GetNumAltSettings() const; virtual size_t GetNumAltSettings() const = 0;
scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting( virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting(
size_t index) const; size_t index) const = 0;
private: protected:
friend class base::RefCounted<const UsbInterfaceDescriptor>; friend class base::RefCounted<const UsbInterfaceDescriptor>;
friend class UsbConfigDescriptor;
UsbInterfaceDescriptor(scoped_refptr<const UsbConfigDescriptor> config, UsbInterfaceDescriptor() {};
PlatformUsbInterface usbInterface); virtual ~UsbInterfaceDescriptor() {};
~UsbInterfaceDescriptor();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbInterface interface_;
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor); DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor);
}; };
...@@ -126,22 +96,15 @@ class USB_SERVICE_EXPORT UsbInterfaceDescriptor ...@@ -126,22 +96,15 @@ class USB_SERVICE_EXPORT UsbInterfaceDescriptor
class USB_SERVICE_EXPORT UsbConfigDescriptor class USB_SERVICE_EXPORT UsbConfigDescriptor
: public base::RefCounted<UsbConfigDescriptor> { : public base::RefCounted<UsbConfigDescriptor> {
public: public:
virtual size_t GetNumInterfaces() const; virtual size_t GetNumInterfaces() const = 0;
virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface( virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface(
size_t index) const; size_t index) const = 0;
protected: protected:
// Constructor called in test only
UsbConfigDescriptor();
virtual ~UsbConfigDescriptor();
private:
friend class base::RefCounted<UsbConfigDescriptor>; friend class base::RefCounted<UsbConfigDescriptor>;
friend class UsbDeviceImpl;
explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config);
PlatformUsbConfigDescriptor config_; UsbConfigDescriptor() {};
virtual ~UsbConfigDescriptor() {};
DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor); DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor);
}; };
......
...@@ -2,27 +2,27 @@ ...@@ -2,27 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/usb_service/usb_interface.h" #include "components/usb_service/usb_interface_impl.h"
#include "base/logging.h" #include "base/logging.h"
#include "third_party/libusb/src/libusb/libusb.h" #include "third_party/libusb/src/libusb/libusb.h"
namespace usb_service { namespace usb_service {
UsbEndpointDescriptor::UsbEndpointDescriptor( UsbEndpointDescriptorImpl::UsbEndpointDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config, scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbEndpointDescriptor descriptor) PlatformUsbEndpointDescriptor descriptor)
: config_(config), descriptor_(descriptor) { : config_(config), descriptor_(descriptor) {
} }
UsbEndpointDescriptor::~UsbEndpointDescriptor() { UsbEndpointDescriptorImpl::~UsbEndpointDescriptorImpl() {
} }
int UsbEndpointDescriptor::GetAddress() const { int UsbEndpointDescriptorImpl::GetAddress() const {
return descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_ADDRESS_MASK; return descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_ADDRESS_MASK;
} }
UsbEndpointDirection UsbEndpointDescriptor::GetDirection() const { UsbEndpointDirection UsbEndpointDescriptorImpl::GetDirection() const {
switch (descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) { switch (descriptor_->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) {
case LIBUSB_ENDPOINT_IN: case LIBUSB_ENDPOINT_IN:
return USB_DIRECTION_INBOUND; return USB_DIRECTION_INBOUND;
...@@ -34,11 +34,12 @@ UsbEndpointDirection UsbEndpointDescriptor::GetDirection() const { ...@@ -34,11 +34,12 @@ UsbEndpointDirection UsbEndpointDescriptor::GetDirection() const {
} }
} }
int UsbEndpointDescriptor::GetMaximumPacketSize() const { int UsbEndpointDescriptorImpl::GetMaximumPacketSize() const {
return descriptor_->wMaxPacketSize; return descriptor_->wMaxPacketSize;
} }
UsbSynchronizationType UsbEndpointDescriptor::GetSynchronizationType() const { UsbSynchronizationType
UsbEndpointDescriptorImpl::GetSynchronizationType() const {
switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) {
case LIBUSB_ISO_SYNC_TYPE_NONE: case LIBUSB_ISO_SYNC_TYPE_NONE:
return USB_SYNCHRONIZATION_NONE; return USB_SYNCHRONIZATION_NONE;
...@@ -54,7 +55,7 @@ UsbSynchronizationType UsbEndpointDescriptor::GetSynchronizationType() const { ...@@ -54,7 +55,7 @@ UsbSynchronizationType UsbEndpointDescriptor::GetSynchronizationType() const {
} }
} }
UsbTransferType UsbEndpointDescriptor::GetTransferType() const { UsbTransferType UsbEndpointDescriptorImpl::GetTransferType() const {
switch (descriptor_->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) { switch (descriptor_->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) {
case LIBUSB_TRANSFER_TYPE_CONTROL: case LIBUSB_TRANSFER_TYPE_CONTROL:
return USB_TRANSFER_CONTROL; return USB_TRANSFER_CONTROL;
...@@ -70,7 +71,7 @@ UsbTransferType UsbEndpointDescriptor::GetTransferType() const { ...@@ -70,7 +71,7 @@ UsbTransferType UsbEndpointDescriptor::GetTransferType() const {
} }
} }
UsbUsageType UsbEndpointDescriptor::GetUsageType() const { UsbUsageType UsbEndpointDescriptorImpl::GetUsageType() const {
switch (descriptor_->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) { switch (descriptor_->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) {
case LIBUSB_ISO_USAGE_TYPE_DATA: case LIBUSB_ISO_USAGE_TYPE_DATA:
return USB_USAGE_DATA; return USB_USAGE_DATA;
...@@ -84,91 +85,84 @@ UsbUsageType UsbEndpointDescriptor::GetUsageType() const { ...@@ -84,91 +85,84 @@ UsbUsageType UsbEndpointDescriptor::GetUsageType() const {
} }
} }
int UsbEndpointDescriptor::GetPollingInterval() const { int UsbEndpointDescriptorImpl::GetPollingInterval() const {
return descriptor_->bInterval; return descriptor_->bInterval;
} }
UsbInterfaceAltSettingDescriptor::UsbInterfaceAltSettingDescriptor( UsbInterfaceAltSettingDescriptorImpl::UsbInterfaceAltSettingDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config, scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterfaceDescriptor descriptor) PlatformUsbInterfaceDescriptor descriptor)
: config_(config), descriptor_(descriptor) { : config_(config), descriptor_(descriptor) {
} }
UsbInterfaceAltSettingDescriptor::~UsbInterfaceAltSettingDescriptor() { UsbInterfaceAltSettingDescriptorImpl::~UsbInterfaceAltSettingDescriptorImpl() {
} }
size_t UsbInterfaceAltSettingDescriptor::GetNumEndpoints() const { size_t UsbInterfaceAltSettingDescriptorImpl::GetNumEndpoints() const {
return descriptor_->bNumEndpoints; return descriptor_->bNumEndpoints;
} }
scoped_refptr<const UsbEndpointDescriptor> scoped_refptr<const UsbEndpointDescriptor>
UsbInterfaceAltSettingDescriptor::GetEndpoint(size_t index) const { UsbInterfaceAltSettingDescriptorImpl::GetEndpoint(size_t index) const {
return new UsbEndpointDescriptor(config_, &descriptor_->endpoint[index]); return new UsbEndpointDescriptorImpl(config_, &descriptor_->endpoint[index]);
} }
int UsbInterfaceAltSettingDescriptor::GetInterfaceNumber() const { int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceNumber() const {
return descriptor_->bInterfaceNumber; return descriptor_->bInterfaceNumber;
} }
int UsbInterfaceAltSettingDescriptor::GetAlternateSetting() const { int UsbInterfaceAltSettingDescriptorImpl::GetAlternateSetting() const {
return descriptor_->bAlternateSetting; return descriptor_->bAlternateSetting;
} }
int UsbInterfaceAltSettingDescriptor::GetInterfaceClass() const { int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceClass() const {
return descriptor_->bInterfaceClass; return descriptor_->bInterfaceClass;
} }
int UsbInterfaceAltSettingDescriptor::GetInterfaceSubclass() const { int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceSubclass() const {
return descriptor_->bInterfaceSubClass; return descriptor_->bInterfaceSubClass;
} }
int UsbInterfaceAltSettingDescriptor::GetInterfaceProtocol() const { int UsbInterfaceAltSettingDescriptorImpl::GetInterfaceProtocol() const {
return descriptor_->bInterfaceProtocol; return descriptor_->bInterfaceProtocol;
} }
UsbInterfaceDescriptor::UsbInterfaceDescriptor( UsbInterfaceDescriptorImpl::UsbInterfaceDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config, scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterface usbInterface) PlatformUsbInterface usbInterface)
: config_(config), interface_(usbInterface) { : config_(config), interface_(usbInterface) {
} }
UsbInterfaceDescriptor::~UsbInterfaceDescriptor() { UsbInterfaceDescriptorImpl::~UsbInterfaceDescriptorImpl() {
} }
size_t UsbInterfaceDescriptor::GetNumAltSettings() const { size_t UsbInterfaceDescriptorImpl::GetNumAltSettings() const {
return interface_->num_altsetting; return interface_->num_altsetting;
} }
scoped_refptr<const UsbInterfaceAltSettingDescriptor> scoped_refptr<const UsbInterfaceAltSettingDescriptor>
UsbInterfaceDescriptor::GetAltSetting(size_t index) const { UsbInterfaceDescriptorImpl::GetAltSetting(size_t index) const {
return new UsbInterfaceAltSettingDescriptor(config_, return new UsbInterfaceAltSettingDescriptorImpl(
&interface_->altsetting[index]); config_, &interface_->altsetting[index]);
} }
UsbConfigDescriptor::UsbConfigDescriptor(PlatformUsbConfigDescriptor config) UsbConfigDescriptorImpl::UsbConfigDescriptorImpl(
PlatformUsbConfigDescriptor config)
: config_(config) { : config_(config) {
DCHECK(config);
} }
// TODO(zvorygin): Used for tests only. Should be removed when UsbConfigDescriptorImpl::~UsbConfigDescriptorImpl() {
// all interfaces are extracted properly. libusb_free_config_descriptor(config_);
UsbConfigDescriptor::UsbConfigDescriptor() {
config_ = NULL;
} }
UsbConfigDescriptor::~UsbConfigDescriptor() { size_t UsbConfigDescriptorImpl::GetNumInterfaces() const {
if (config_ != NULL) {
libusb_free_config_descriptor(config_);
config_ = NULL;
}
}
size_t UsbConfigDescriptor::GetNumInterfaces() const {
return config_->bNumInterfaces; return config_->bNumInterfaces;
} }
scoped_refptr<const UsbInterfaceDescriptor> UsbConfigDescriptor::GetInterface( scoped_refptr<const UsbInterfaceDescriptor>
size_t index) const { UsbConfigDescriptorImpl::GetInterface(size_t index) const {
return new UsbInterfaceDescriptor(this, &config_->interface[index]); return new UsbInterfaceDescriptorImpl(this, &config_->interface[index]);
} }
} // namespace usb_service } // namespace usb_service
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
#define COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
#include "base/memory/ref_counted.h"
#include "components/usb_service/usb_interface.h"
#include "components/usb_service/usb_service_export.h"
struct libusb_config_descriptor;
struct libusb_endpoint_descriptor;
struct libusb_interface;
struct libusb_interface_descriptor;
namespace usb_service {
typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor;
typedef const libusb_interface* PlatformUsbInterface;
typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor;
class UsbConfigDescriptorImpl;
class UsbInterfaceAltSettingDescriptor;
class UsbEndpointDescriptorImpl : public UsbEndpointDescriptor {
public:
virtual int GetAddress() const OVERRIDE;
virtual UsbEndpointDirection GetDirection() const OVERRIDE;
virtual int GetMaximumPacketSize() const OVERRIDE;
virtual UsbSynchronizationType GetSynchronizationType() const OVERRIDE;
virtual UsbTransferType GetTransferType() const OVERRIDE;
virtual UsbUsageType GetUsageType() const OVERRIDE;
virtual int GetPollingInterval() const OVERRIDE;
private:
friend class base::RefCounted<const UsbEndpointDescriptorImpl>;
friend class UsbInterfaceAltSettingDescriptorImpl;
UsbEndpointDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbEndpointDescriptor descriptor);
virtual ~UsbEndpointDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbEndpointDescriptor descriptor_;
DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptorImpl);
};
class UsbInterfaceAltSettingDescriptorImpl
: public UsbInterfaceAltSettingDescriptor {
public:
virtual size_t GetNumEndpoints() const OVERRIDE;
virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(
size_t index) const OVERRIDE;
virtual int GetInterfaceNumber() const OVERRIDE;
virtual int GetAlternateSetting() const OVERRIDE;
virtual int GetInterfaceClass() const OVERRIDE;
virtual int GetInterfaceSubclass() const OVERRIDE;
virtual int GetInterfaceProtocol() const OVERRIDE;
private:
friend class UsbInterfaceDescriptorImpl;
UsbInterfaceAltSettingDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterfaceDescriptor descriptor);
virtual ~UsbInterfaceAltSettingDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbInterfaceDescriptor descriptor_;
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptorImpl);
};
class UsbInterfaceDescriptorImpl : public UsbInterfaceDescriptor {
public:
virtual size_t GetNumAltSettings() const OVERRIDE;
virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting(
size_t index) const OVERRIDE;
private:
friend class base::RefCounted<const UsbInterfaceDescriptorImpl>;
friend class UsbConfigDescriptorImpl;
UsbInterfaceDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterface usbInterface);
virtual ~UsbInterfaceDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbInterface interface_;
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptorImpl);
};
class UsbConfigDescriptorImpl : public UsbConfigDescriptor {
public:
virtual size_t GetNumInterfaces() const OVERRIDE;
virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface(
size_t index) const OVERRIDE;
private:
friend class base::RefCounted<UsbConfigDescriptor>;
friend class UsbDeviceImpl;
explicit UsbConfigDescriptorImpl(PlatformUsbConfigDescriptor config);
virtual ~UsbConfigDescriptorImpl();
PlatformUsbConfigDescriptor config_;
DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptorImpl);
};
} // namespace usb_service;
#endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
...@@ -19,6 +19,7 @@ using usb_service::UsbConfigDescriptor; ...@@ -19,6 +19,7 @@ using usb_service::UsbConfigDescriptor;
using usb_service::UsbDevice; using usb_service::UsbDevice;
using usb_service::UsbDeviceHandle; using usb_service::UsbDeviceHandle;
using usb_service::UsbEndpointDirection; using usb_service::UsbEndpointDirection;
using usb_service::UsbInterfaceDescriptor;
using usb_service::UsbService; using usb_service::UsbService;
using usb_service::UsbTransferCallback; using usb_service::UsbTransferCallback;
...@@ -95,6 +96,8 @@ class MockUsbDeviceHandle : public UsbDeviceHandle { ...@@ -95,6 +96,8 @@ class MockUsbDeviceHandle : public UsbDeviceHandle {
class MockUsbConfigDescriptor : public UsbConfigDescriptor { class MockUsbConfigDescriptor : public UsbConfigDescriptor {
public: public:
MOCK_CONST_METHOD0(GetNumInterfaces, size_t()); MOCK_CONST_METHOD0(GetNumInterfaces, size_t());
MOCK_CONST_METHOD1(GetInterface,
scoped_refptr<const UsbInterfaceDescriptor>(size_t index));
protected: protected:
virtual ~MockUsbConfigDescriptor() {} virtual ~MockUsbConfigDescriptor() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment