| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_ | 5 #ifndef DEVICE_HID_HID_CONNECTION_WIN_H_ |
| 6 #define DEVICE_HID_HID_CONNECTION_WIN_H_ | 6 #define DEVICE_HID_HID_CONNECTION_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/win/scoped_handle.h" |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/message_loop/message_loop.h" | |
| 15 #include "base/threading/thread_checker.h" | |
| 16 #include "device/hid/hid_connection.h" | 13 #include "device/hid/hid_connection.h" |
| 17 #include "device/hid/hid_device_info.h" | |
| 18 | 14 |
| 19 namespace device { | 15 namespace device { |
| 20 | 16 |
| 21 struct PendingHidTransfer; | 17 struct PendingHidTransfer; |
| 22 | 18 |
| 23 class HidConnectionWin : public HidConnection { | 19 class HidConnectionWin : public HidConnection { |
| 24 public: | 20 public: |
| 25 explicit HidConnectionWin(const HidDeviceInfo& device_info); | 21 explicit HidConnectionWin(const HidDeviceInfo& device_info); |
| 26 | 22 |
| 27 bool available() const; | 23 // HidConnection implementation. |
| 24 virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer, |
| 25 const IOCallback& callback) OVERRIDE; |
| 26 virtual void PlatformWrite(uint8_t report_id, |
| 27 scoped_refptr<net::IOBufferWithSize> buffer, |
| 28 const IOCallback& callback) OVERRIDE; |
| 29 virtual void PlatformGetFeatureReport( |
| 30 uint8_t report_id, |
| 31 scoped_refptr<net::IOBufferWithSize> buffer, |
| 32 const IOCallback& callback) OVERRIDE; |
| 33 virtual void PlatformSendFeatureReport( |
| 34 uint8_t report_id, |
| 35 scoped_refptr<net::IOBufferWithSize> buffer, |
| 36 const IOCallback& callback) OVERRIDE; |
| 28 | 37 |
| 29 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, | 38 private: |
| 30 const IOCallback& callback) OVERRIDE; | 39 friend class HidServiceWin; |
| 31 virtual void Write(uint8_t report_id, | 40 friend struct PendingHidTransfer; |
| 32 scoped_refptr<net::IOBufferWithSize> buffer, | 41 |
| 33 const IOCallback& callback) OVERRIDE; | 42 ~HidConnectionWin(); |
| 34 virtual void GetFeatureReport(uint8_t report_id, | 43 |
| 35 scoped_refptr<net::IOBufferWithSize> buffer, | 44 bool available() const { return file_.IsValid(); } |
| 36 const IOCallback& callback) OVERRIDE; | |
| 37 virtual void SendFeatureReport(uint8_t report_id, | |
| 38 scoped_refptr<net::IOBufferWithSize> buffer, | |
| 39 const IOCallback& callback) OVERRIDE; | |
| 40 | 45 |
| 41 void OnTransferFinished(scoped_refptr<PendingHidTransfer> transfer); | 46 void OnTransferFinished(scoped_refptr<PendingHidTransfer> transfer); |
| 42 void OnTransferCanceled(scoped_refptr<PendingHidTransfer> transfer); | 47 void OnTransferCanceled(scoped_refptr<PendingHidTransfer> transfer); |
| 43 | 48 |
| 44 private: | 49 base::win::ScopedHandle file_; |
| 45 ~HidConnectionWin(); | |
| 46 | 50 |
| 47 base::win::ScopedHandle file_; | |
| 48 std::set<scoped_refptr<PendingHidTransfer> > transfers_; | 51 std::set<scoped_refptr<PendingHidTransfer> > transfers_; |
| 49 | 52 |
| 50 base::ThreadChecker thread_checker_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); | 53 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 } // namespace device | 56 } // namespace device |
| 56 | 57 |
| 57 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ | 58 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ |
| OLD | NEW |