summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorzvorygin@chromium.org <zvorygin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-12 16:58:52 +0000
committerzvorygin@chromium.org <zvorygin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-12 16:58:52 +0000
commitd738857a73566e03820bfc3c826585f62db378c9 (patch)
tree5d74ac9fccd3613d5a88b19d548d488907effc52 /extensions
parent2ebf2604bb2fa3f2013c9b29c9d5bcadd493b5a6 (diff)
downloadchromium_src-d738857a73566e03820bfc3c826585f62db378c9.zip
chromium_src-d738857a73566e03820bfc3c826585f62db378c9.tar.gz
chromium_src-d738857a73566e03820bfc3c826585f62db378c9.tar.bz2
Extracted UsbDeviceHandle as interface.
BUG=367094 Review URL: https://codereview.chromium.org/278633003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/api/usb/usb_api.cc12
-rw-r--r--extensions/browser/api/usb/usb_apitest.cc11
2 files changed, 17 insertions, 6 deletions
diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc
index 93ac6c1..428439a 100644
--- a/extensions/browser/api/usb/usb_api.cc
+++ b/extensions/browser/api/usb/usb_api.cc
@@ -464,15 +464,15 @@ UsbAsyncApiFunction::GetDeviceHandleOrCompleteWithError(
return NULL;
}
- if (!resource->device() || !resource->device()->device()) {
+ if (!resource->device() || !resource->device()->GetDevice()) {
CompleteWithError(kErrorDisconnect);
manager_->Remove(extension_->id(), input_device_handle.handle);
return NULL;
}
- if (resource->device()->device()->vendor_id() !=
+ if (resource->device()->GetDevice()->vendor_id() !=
input_device_handle.vendor_id ||
- resource->device()->device()->product_id() !=
+ resource->device()->GetDevice()->product_id() !=
input_device_handle.product_id) {
CompleteWithError(kErrorNoDevice);
return NULL;
@@ -721,8 +721,8 @@ void UsbOpenDeviceFunction::AsyncWorkStart() {
SetResult(PopulateConnectionHandle(
manager_->Add(new UsbDeviceResource(extension_->id(), handle_)),
- handle_->device()->vendor_id(),
- handle_->device()->product_id()));
+ handle_->GetDevice()->vendor_id(),
+ handle_->GetDevice()->product_id()));
AsyncWorkCompleted();
}
@@ -745,7 +745,7 @@ void UsbListInterfacesFunction::AsyncWorkStart() {
return;
scoped_refptr<UsbConfigDescriptor> config =
- device_handle->device()->ListInterfaces();
+ device_handle->GetDevice()->ListInterfaces();
if (!config) {
SetError(kErrorCannotListInterfaces);
diff --git a/extensions/browser/api/usb/usb_apitest.cc b/extensions/browser/api/usb/usb_apitest.cc
index a75ad16b..3d6788d 100644
--- a/extensions/browser/api/usb/usb_apitest.cc
+++ b/extensions/browser/api/usb/usb_apitest.cc
@@ -86,10 +86,21 @@ class MockUsbDeviceHandle : public UsbDeviceHandle {
const UsbTransferCallback& callback));
MOCK_METHOD0(ResetDevice, bool());
+ MOCK_METHOD1(ClaimInterface, bool(const int interface_number));
+ MOCK_METHOD1(ReleaseInterface, bool(const int interface_number));
+ MOCK_METHOD2(SetInterfaceAlternateSetting,
+ bool(const int interface_number, const int alternate_setting));
+ MOCK_METHOD1(GetSerial, bool(base::string16* serial));
+
+ virtual scoped_refptr<UsbDevice> GetDevice() const OVERRIDE {
+ return device_;
+ }
void set_device(UsbDevice* device) { device_ = device; }
protected:
+ UsbDevice* device_;
+
virtual ~MockUsbDeviceHandle() {}
};