forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscoped_winusb_handle.h
38 lines (26 loc) · 940 Bytes
/
scoped_winusb_handle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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_