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_MAC_H_ | 5 #ifndef DEVICE_HID_HID_CONNECTION_MAC_H_ |
6 #define DEVICE_HID_HID_CONNECTION_MAC_H_ | 6 #define DEVICE_HID_HID_CONNECTION_MAC_H_ |
7 | 7 |
8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
9 #include <IOKit/hid/IOHIDManager.h> | 9 #include <IOKit/hid/IOHIDManager.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace net { | 21 namespace net { |
22 class IOBuffer; | 22 class IOBuffer; |
23 } | 23 } |
24 | 24 |
25 namespace device { | 25 namespace device { |
26 | 26 |
27 class HidConnectionMac : public HidConnection { | 27 class HidConnectionMac : public HidConnection { |
28 public: | 28 public: |
29 explicit HidConnectionMac(HidDeviceInfo device_info); | 29 explicit HidConnectionMac(HidDeviceInfo device_info); |
30 | 30 |
31 // HidConnection implementation. | |
32 virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer, | |
33 const IOCallback& callback) OVERRIDE; | |
34 virtual void PlatformWrite(uint8_t report_id, | |
35 scoped_refptr<net::IOBufferWithSize> buffer, | |
36 const IOCallback& callback) OVERRIDE; | |
37 virtual void PlatformGetFeatureReport( | |
38 uint8_t report_id, | |
39 scoped_refptr<net::IOBufferWithSize> buffer, | |
40 const IOCallback& callback) OVERRIDE; | |
41 virtual void PlatformSendFeatureReport( | |
42 uint8_t report_id, | |
43 scoped_refptr<net::IOBufferWithSize> buffer, | |
44 const IOCallback& callback) OVERRIDE; | |
45 | |
46 private: | 31 private: |
47 virtual ~HidConnectionMac(); | 32 virtual ~HidConnectionMac(); |
48 | 33 |
| 34 // HidConnection implementation. |
| 35 virtual void PlatformRead(const ReadCallback& callback) OVERRIDE; |
| 36 virtual void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, |
| 37 size_t size, |
| 38 const WriteCallback& callback) OVERRIDE; |
| 39 virtual void PlatformGetFeatureReport(uint8_t report_id, |
| 40 const ReadCallback& callback) OVERRIDE; |
| 41 virtual void PlatformSendFeatureReport( |
| 42 scoped_refptr<net::IOBuffer> buffer, |
| 43 size_t size, |
| 44 const WriteCallback& callback) OVERRIDE; |
| 45 |
49 static void InputReportCallback(void* context, | 46 static void InputReportCallback(void* context, |
50 IOReturn result, | 47 IOReturn result, |
51 void* sender, | 48 void* sender, |
52 IOHIDReportType type, | 49 IOHIDReportType type, |
53 uint32_t report_id, | 50 uint32_t report_id, |
54 uint8_t* report_bytes, | 51 uint8_t* report_bytes, |
55 CFIndex report_length); | 52 CFIndex report_length); |
56 | 53 |
57 void WriteReport(IOHIDReportType type, | 54 void WriteReport(IOHIDReportType type, |
58 uint8_t report_id, | 55 scoped_refptr<net::IOBuffer> buffer, |
59 scoped_refptr<net::IOBufferWithSize> buffer, | 56 size_t size, |
60 const IOCallback& callback); | 57 const WriteCallback& callback); |
61 | 58 |
62 void Flush(); | 59 void Flush(); |
63 void ProcessInputReport(scoped_refptr<net::IOBufferWithSize> buffer); | 60 void ProcessInputReport(scoped_refptr<net::IOBufferWithSize> buffer); |
64 void ProcessReadQueue(); | 61 void ProcessReadQueue(); |
65 | 62 |
66 base::ScopedCFTypeRef<IOHIDDeviceRef> device_; | 63 base::ScopedCFTypeRef<IOHIDDeviceRef> device_; |
67 scoped_refptr<base::MessageLoopProxy> message_loop_; | 64 scoped_refptr<base::MessageLoopProxy> message_loop_; |
68 scoped_ptr<uint8_t, base::FreeDeleter> inbound_buffer_; | 65 scoped_ptr<uint8_t[]> inbound_buffer_; |
69 | 66 |
70 std::queue<PendingHidReport> pending_reports_; | 67 std::queue<PendingHidReport> pending_reports_; |
71 std::queue<PendingHidRead> pending_reads_; | 68 std::queue<PendingHidRead> pending_reads_; |
72 | 69 |
73 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); | 70 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); |
74 }; | 71 }; |
75 | 72 |
76 } // namespace device | 73 } // namespace device |
77 | 74 |
78 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ | 75 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ |
OLD | NEW |