1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_
6 #define DEVICE_HID_HID_CONNECTION_WIN_H_
12 #include "base/win/scoped_handle.h"
13 #include "device/hid/hid_connection.h"
17 struct PendingHidTransfer;
19 class HidConnectionWin : public HidConnection {
21 explicit HidConnectionWin(const HidDeviceInfo& device_info);
24 friend class HidServiceWin;
25 friend struct PendingHidTransfer;
29 // HidConnection implementation.
30 virtual void PlatformClose() override;
31 virtual void PlatformRead(const ReadCallback& callback) override;
32 virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
34 const WriteCallback& callback) override;
35 virtual void PlatformGetFeatureReport(uint8_t report_id,
36 const ReadCallback& callback) override;
37 virtual void PlatformSendFeatureReport(
38 scoped_refptr<net::IOBuffer> buffer,
40 const WriteCallback& callback) override;
42 bool available() const { return file_.IsValid(); }
44 void OnReadComplete(scoped_refptr<net::IOBuffer> buffer,
45 const ReadCallback& callback,
46 PendingHidTransfer* transfer,
48 void OnReadFeatureComplete(scoped_refptr<net::IOBuffer> buffer,
49 const ReadCallback& callback,
50 PendingHidTransfer* transfer,
52 void OnWriteComplete(const WriteCallback& callback,
53 PendingHidTransfer* transfer,
56 base::win::ScopedHandle file_;
58 std::set<scoped_refptr<PendingHidTransfer> > transfers_;
60 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin);
65 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_