forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start supporting some transfers in the new Windows USB backend
This patch starts adding support for opening USB devices and issuing requests to them when using the new Windows USB backend. Only non- composite devices are supported currently as enumerating the device paths for composite devices is more complex. This has been tested with a WebLight which is a non-composite device that only requires control transfers. Bug: 637404 Change-Id: Ib792896435106bd03b3d5743608be44a22d4b153 Reviewed-on: https://chromium-review.googlesource.com/834887 Commit-Queue: Reilly Grant <reillyg@chromium.org> Reviewed-by: Matt Reynolds <mattreynolds@chromium.org> Cr-Commit-Position: refs/heads/master@{#525253}
- Loading branch information
Showing
7 changed files
with
529 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2017 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. | ||
|
||
#include "device/usb/scoped_winusb_handle.h" | ||
|
||
#include <windows.h> | ||
#include <winusb.h> | ||
|
||
namespace device { | ||
|
||
bool WinUsbHandleTraits::CloseHandle(Handle handle) { | ||
return WinUsb_Free(handle) == TRUE; | ||
} | ||
|
||
} // namespace device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2017 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 DEVICE_USB_SCOPED_WINUSB_HANDLE_H_ | ||
#define DEVICE_USB_SCOPED_WINUSB_HANDLE_H_ | ||
|
||
#include "base/win/scoped_handle.h" | ||
|
||
extern "C" { | ||
typedef void* WINUSB_INTERFACE_HANDLE; | ||
} | ||
|
||
namespace device { | ||
|
||
class WinUsbHandleTraits { | ||
public: | ||
using Handle = WINUSB_INTERFACE_HANDLE; | ||
|
||
static bool CloseHandle(Handle handle); | ||
|
||
static bool IsHandleValid(Handle handle) { | ||
return handle != nullptr && handle != INVALID_HANDLE_VALUE; | ||
} | ||
|
||
static Handle NullHandle() { return nullptr; } | ||
|
||
private: | ||
DISALLOW_IMPLICIT_CONSTRUCTORS(WinUsbHandleTraits); | ||
}; | ||
|
||
using ScopedWinUsbHandle = | ||
base::win::GenericScopedHandle<WinUsbHandleTraits, | ||
base::win::DummyVerifierTraits>; | ||
|
||
} // namespace device | ||
|
||
#endif // DEVICE_USB_SCOPED_WINUSB_HANDLE_H_ |
Oops, something went wrong.