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. 4 5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_ 6 #define DEVICE_HID_HID_CONNECTION_WIN_H_ 7 8 #include <windows.h> 9 10 #include <set> 11 12 #include "base/win/scoped_handle.h" 13 #include "device/hid/hid_connection.h" 14 15 namespace device { 16 17 struct PendingHidTransfer; 18 19 class HidConnectionWin : public HidConnection { 20 public: 21 explicit HidConnectionWin(const HidDeviceInfo& device_info); 22 23 private: 24 friend class HidServiceWin; 25 friend struct PendingHidTransfer; 26 27 ~HidConnectionWin(); 28 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, 33 size_t size, 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, 39 size_t size, 40 const WriteCallback& callback) OVERRIDE; 41 42 bool available() const { return file_.IsValid(); } 43 44 void OnReadComplete(scoped_refptr<net::IOBuffer> buffer, 45 const ReadCallback& callback, 46 PendingHidTransfer* transfer, 47 bool signaled); 48 void OnReadFeatureComplete(scoped_refptr<net::IOBuffer> buffer, 49 const ReadCallback& callback, 50 PendingHidTransfer* transfer, 51 bool signaled); 52 void OnWriteComplete(const WriteCallback& callback, 53 PendingHidTransfer* transfer, 54 bool signaled); 55 56 base::win::ScopedHandle file_; 57 58 std::set<scoped_refptr<PendingHidTransfer> > transfers_; 59 60 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); 61 }; 62 63 } // namespace device 64 65 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ 66