Chromium Code Reviews| 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 "base/callback.h" | 8 #include <CoreFoundation/CoreFoundation.h> |
| 9 #include <IOKit/hid/IOHIDManager.h> | |
| 10 #include <queue> | |
|
Mark Mentovai
2014/02/19 22:48:15
Chrome always puts a blank line between the C syst
Ken Rockot(use gerrit already)
2014/02/21 02:15:36
Done.
| |
| 11 | |
| 12 #include "base/mac/foundation_util.h" | |
| 9 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 10 #include "base/tuple.h" | 14 #include "base/tuple.h" |
| 11 #include "device/hid/hid_connection.h" | 15 #include "device/hid/hid_connection.h" |
| 12 #include "device/hid/hid_device_info.h" | 16 #include "device/hid/hid_device_info.h" |
| 13 #include "device/hid/hid_service_mac.h" | |
| 14 | 17 |
| 15 namespace net { | 18 namespace net { |
| 16 class IOBuffer; | 19 class IOBuffer; |
| 17 } | 20 } |
| 18 | 21 |
| 19 namespace device { | 22 namespace device { |
| 20 | 23 |
| 24 struct PendingHidReport { | |
| 25 PendingHidReport(); | |
| 26 ~PendingHidReport(); | |
| 27 | |
| 28 scoped_refptr<net::IOBuffer> buffer; | |
|
Mark Mentovai
2014/02/19 22:48:15
net::IOBuffer + size = net::IOBufferWithSize?
Sam
Ken Rockot(use gerrit already)
2014/02/21 02:15:36
Done all over the place.
| |
| 29 size_t size; | |
| 30 }; | |
| 31 | |
| 32 struct PendingHidRead { | |
| 33 PendingHidRead(); | |
| 34 ~PendingHidRead(); | |
| 35 | |
| 36 scoped_refptr<net::IOBuffer> buffer; | |
| 37 size_t size; | |
| 38 HidConnection::IOCallback callback; | |
| 39 }; | |
| 40 | |
| 41 class HidServiceMac; | |
| 42 | |
| 21 class HidConnectionMac : public HidConnection { | 43 class HidConnectionMac : public HidConnection { |
| 22 public: | 44 public: |
| 23 HidConnectionMac(HidServiceMac* service, | 45 HidConnectionMac(HidServiceMac* service, |
| 24 HidDeviceInfo device_info, | 46 HidDeviceInfo device_info, |
| 25 IOHIDDeviceRef device); | 47 IOHIDDeviceRef device); |
| 26 | 48 |
| 27 virtual void Read(scoped_refptr<net::IOBuffer> buffer, | 49 virtual void Read(scoped_refptr<net::IOBuffer> buffer, |
| 28 size_t size, | 50 size_t size, |
| 29 const IOCallback& callback) OVERRIDE; | 51 const IOCallback& callback) OVERRIDE; |
| 30 virtual void Write(scoped_refptr<net::IOBuffer> buffer, | 52 virtual void Write(scoped_refptr<net::IOBuffer> buffer, |
| 31 size_t size, | 53 size_t size, |
| 32 const IOCallback& callback) OVERRIDE; | 54 const IOCallback& callback) OVERRIDE; |
| 33 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, | 55 virtual void GetFeatureReport(scoped_refptr<net::IOBuffer> buffer, |
| 34 size_t size, | 56 size_t size, |
| 35 const IOCallback& callback) OVERRIDE; | 57 const IOCallback& callback) OVERRIDE; |
| 36 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, | 58 virtual void SendFeatureReport(scoped_refptr<net::IOBuffer> buffer, |
| 37 size_t size, | 59 size_t size, |
| 38 const IOCallback& callback) OVERRIDE; | 60 const IOCallback& callback) OVERRIDE; |
| 39 | 61 |
| 40 private: | 62 private: |
| 41 virtual ~HidConnectionMac(); | 63 virtual ~HidConnectionMac(); |
| 42 | 64 |
| 43 static void InputReportCallback(void * context, | 65 static void InputReportCallback(void* context, |
| 44 IOReturn result, | 66 IOReturn result, |
| 45 void * sender, | 67 void* sender, |
| 46 IOHIDReportType type, | 68 IOHIDReportType type, |
| 47 uint32_t reportID, | 69 uint32_t report_id, |
| 48 uint8_t * report, | 70 uint8_t* report_bytes, |
| 49 CFIndex reportLength); | 71 CFIndex reportLength); |
|
Mark Mentovai
2014/02/19 22:48:15
report_length. Same on line 75 and in the .cc file
Ken Rockot(use gerrit already)
2014/02/21 02:15:36
Done.
| |
| 50 void ProcessReadQueue(); | 72 void ProcessReadQueue(); |
| 51 void ProcessInputReport(IOHIDReportType type, | 73 void ProcessInputReport(IOHIDReportType type, |
| 52 scoped_refptr<net::IOBuffer> report, | 74 scoped_refptr<net::IOBuffer> buffer, |
| 53 CFIndex reportLength); | 75 CFIndex reportLength); |
| 54 | 76 |
| 55 void WriteReport(IOHIDReportType type, | 77 void WriteReport(IOHIDReportType type, |
| 56 scoped_refptr<net::IOBuffer> buffer, | 78 scoped_refptr<net::IOBuffer> buffer, |
| 57 size_t size, | 79 size_t size, |
| 58 const IOCallback& callback); | 80 const IOCallback& callback); |
| 59 | 81 |
| 82 // The HidService that created this connection. Not owned. | |
| 60 HidServiceMac* service_; | 83 HidServiceMac* service_; |
| 84 | |
| 61 scoped_refptr<base::MessageLoopProxy> message_loop_; | 85 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 86 | |
| 62 base::ScopedCFTypeRef<IOHIDDeviceRef> device_; | 87 base::ScopedCFTypeRef<IOHIDDeviceRef> device_; |
| 63 scoped_ptr_malloc<uint8_t> inbound_buffer_; | 88 scoped_ptr_malloc<uint8_t> inbound_buffer_; |
|
Mark Mentovai
2014/02/19 22:48:15
#include "base/memory/scoped_ptr.h" to be able to
Ken Rockot(use gerrit already)
2014/02/21 02:15:36
Done.
| |
| 64 bool disconnected_; | |
| 65 | 89 |
| 66 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> PendingReport; | 90 std::queue<PendingHidReport> pending_reports_; |
| 67 std::queue<PendingReport> input_reports_; | 91 std::queue<PendingHidRead> pending_reads_; |
| 68 typedef Tuple3<scoped_refptr<net::IOBuffer>, size_t, IOCallback> PendingRead; | |
| 69 std::queue<PendingRead> read_queue_; | |
| 70 | 92 |
| 71 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); | 93 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); |
| 72 }; | 94 }; |
| 73 | 95 |
| 74 | 96 |
| 75 } // namespace device | 97 } // namespace device |
| 76 | 98 |
| 77 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ | 99 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ |
| OLD | NEW |