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/win/scoped_handle.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/threading/thread_checker.h" |
13 #include "device/hid/hid_connection.h" | 16 #include "device/hid/hid_connection.h" |
| 17 #include "device/hid/hid_device_info.h" |
14 | 18 |
15 namespace device { | 19 namespace device { |
16 | 20 |
17 struct PendingHidTransfer; | 21 struct PendingHidTransfer; |
18 | 22 |
19 class HidConnectionWin : public HidConnection { | 23 class HidConnectionWin : public HidConnection { |
20 public: | 24 public: |
21 explicit HidConnectionWin(const HidDeviceInfo& device_info); | 25 explicit HidConnectionWin(const HidDeviceInfo& device_info); |
22 | 26 |
23 // HidConnection implementation. | 27 bool available() const; |
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; | |
37 | 28 |
38 private: | 29 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, |
39 friend class HidServiceWin; | 30 const IOCallback& callback) OVERRIDE; |
40 friend struct PendingHidTransfer; | 31 virtual void Write(uint8_t report_id, |
41 | 32 scoped_refptr<net::IOBufferWithSize> buffer, |
42 ~HidConnectionWin(); | 33 const IOCallback& callback) OVERRIDE; |
43 | 34 virtual void GetFeatureReport(uint8_t report_id, |
44 bool available() const { return file_.IsValid(); } | 35 scoped_refptr<net::IOBufferWithSize> buffer, |
| 36 const IOCallback& callback) OVERRIDE; |
| 37 virtual void SendFeatureReport(uint8_t report_id, |
| 38 scoped_refptr<net::IOBufferWithSize> buffer, |
| 39 const IOCallback& callback) OVERRIDE; |
45 | 40 |
46 void OnTransferFinished(scoped_refptr<PendingHidTransfer> transfer); | 41 void OnTransferFinished(scoped_refptr<PendingHidTransfer> transfer); |
47 void OnTransferCanceled(scoped_refptr<PendingHidTransfer> transfer); | 42 void OnTransferCanceled(scoped_refptr<PendingHidTransfer> transfer); |
48 | 43 |
| 44 private: |
| 45 ~HidConnectionWin(); |
| 46 |
49 base::win::ScopedHandle file_; | 47 base::win::ScopedHandle file_; |
| 48 std::set<scoped_refptr<PendingHidTransfer> > transfers_; |
50 | 49 |
51 std::set<scoped_refptr<PendingHidTransfer> > transfers_; | 50 base::ThreadChecker thread_checker_; |
52 | 51 |
53 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); | 52 DISALLOW_COPY_AND_ASSIGN(HidConnectionWin); |
54 }; | 53 }; |
55 | 54 |
56 } // namespace device | 55 } // namespace device |
57 | 56 |
58 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ | 57 #endif // DEVICE_HID_HID_CONNECTION_WIN_H_ |
OLD | NEW |