| OLD | NEW |
| (Empty) | |
| 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_MAC_H_ |
| 6 #define DEVICE_HID_HID_CONNECTION_MAC_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "device/hid/hid_connection.h" |
| 11 #include "device/hid/hid_device_info.h" |
| 12 #include "device/hid/hid_service_mac.h" |
| 13 |
| 14 namespace net { |
| 15 class IOBuffer; |
| 16 } |
| 17 |
| 18 namespace device { |
| 19 |
| 20 class HidConnectionMac : public HidConnection { |
| 21 public: |
| 22 HidConnectionMac(HidServiceMac* service, |
| 23 HidDeviceInfo device_info, |
| 24 IOHIDDeviceRef device); |
| 25 |
| 26 virtual void Read(const HidIOCallback& callback) OVERRIDE; |
| 27 virtual void Write(scoped_refptr<net::IOBuffer> buffer, |
| 28 size_t size, |
| 29 const HidIOCallback& callback) OVERRIDE; |
| 30 virtual void GetFeatureReport(const HidIOCallback& callback) OVERRIDE; |
| 31 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, |
| 32 size_t size, |
| 33 const HidIOCallback& callback) OVERRIDE; |
| 34 |
| 35 private: |
| 36 virtual ~HidConnectionMac(); |
| 37 |
| 38 static void InputReportCallback(void * context, |
| 39 IOReturn result, |
| 40 void * sender, |
| 41 IOHIDReportType type, |
| 42 uint32_t reportID, |
| 43 uint8_t * report, |
| 44 CFIndex reportLength); |
| 45 void ProcessReadQueue(); |
| 46 void ProcessInputReport(IOHIDReportType type, |
| 47 scoped_refptr<net::IOBuffer> report, |
| 48 CFIndex reportLength); |
| 49 |
| 50 void WriteReport(IOHIDReportType type, |
| 51 scoped_refptr<net::IOBuffer> buffer, |
| 52 size_t size, |
| 53 const HidIOCallback& callback); |
| 54 |
| 55 HidServiceMac* service_; |
| 56 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 57 base::ScopedCFTypeRef<IOHIDDeviceRef> device_; |
| 58 scoped_ptr_malloc<uint8_t> inbound_buffer_; |
| 59 bool disconnected_; |
| 60 std::queue<std::pair<scoped_refptr<net::IOBuffer>, size_t> > input_reports_; |
| 61 std::queue<HidIOCallback> read_queue_; |
| 62 |
| 63 base::ThreadChecker thread_checker_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); |
| 66 }; |
| 67 |
| 68 |
| 69 } // namespace device |
| 70 |
| 71 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ |
| OLD | NEW |