Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: device/hid/hid_connection_mac.h

Issue 317783010: chrome.hid: enrich model with report IDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Filter reports + refactor HID connections (ongoing) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include <queue>
12
13 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
16 #include "base/threading/thread_checker.h"
17 #include "device/hid/hid_connection.h" 13 #include "device/hid/hid_connection.h"
18 #include "device/hid/hid_device_info.h"
19 14
20 namespace base { 15 namespace base {
21 class MessageLoopProxy; 16 class MessageLoopProxy;
22 } 17 }
23 18
24 namespace net { 19 namespace net {
25 class IOBuffer; 20 class IOBuffer;
26 } 21 }
27 22
28 namespace device { 23 namespace device {
29 24
30 class HidConnectionMac : public HidConnection { 25 class HidConnectionMac : public HidConnection2 {
31 public: 26 public:
32 explicit HidConnectionMac(HidDeviceInfo device_info); 27 explicit HidConnectionMac(HidDeviceInfo device_info);
33 28
34 virtual void Read(scoped_refptr<net::IOBufferWithSize> buffer, 29 // HidConnection implementation.
35 const IOCallback& callback) OVERRIDE; 30 virtual void PlatformRead(scoped_refptr<net::IOBufferWithSize> buffer,
36 virtual void Write(uint8_t report_id, 31 const IOCallback& callback) OVERRIDE;
37 scoped_refptr<net::IOBufferWithSize> buffer, 32 virtual void PlatformWrite(uint8_t report_id,
38 const IOCallback& callback) OVERRIDE; 33 scoped_refptr<net::IOBufferWithSize> buffer,
39 virtual void GetFeatureReport(uint8_t report_id, 34 const IOCallback& callback) OVERRIDE;
40 scoped_refptr<net::IOBufferWithSize> buffer, 35 virtual void PlatformGetFeatureReport(
41 const IOCallback& callback) OVERRIDE; 36 uint8_t report_id,
42 virtual void SendFeatureReport(uint8_t report_id, 37 scoped_refptr<net::IOBufferWithSize> buffer,
43 scoped_refptr<net::IOBufferWithSize> buffer, 38 const IOCallback& callback) OVERRIDE;
44 const IOCallback& callback) OVERRIDE; 39 virtual void PlatformSendFeatureReport(
40 uint8_t report_id,
41 scoped_refptr<net::IOBufferWithSize> buffer,
42 const IOCallback& callback) OVERRIDE;
45 43
46 private: 44 private:
47 virtual ~HidConnectionMac(); 45 virtual ~HidConnectionMac();
48 46
49 static void InputReportCallback(void* context, 47 static void InputReportCallback(void* context,
50 IOReturn result, 48 IOReturn result,
51 void* sender, 49 void* sender,
52 IOHIDReportType type, 50 IOHIDReportType type,
53 uint32_t report_id, 51 uint32_t report_id,
54 uint8_t* report_bytes, 52 uint8_t* report_bytes,
55 CFIndex report_length); 53 CFIndex report_length);
56 void ProcessReadQueue();
57 void ProcessInputReport(IOHIDReportType type,
58 scoped_refptr<net::IOBufferWithSize> buffer);
59 54
60 void WriteReport(IOHIDReportType type, 55 void WriteReport(IOHIDReportType type,
61 uint8_t report_id, 56 uint8_t report_id,
62 scoped_refptr<net::IOBufferWithSize> buffer, 57 scoped_refptr<net::IOBufferWithSize> buffer,
63 const IOCallback& callback); 58 const IOCallback& callback);
64 59
60 base::ScopedCFTypeRef<IOHIDDeviceRef> device_;
65 scoped_refptr<base::MessageLoopProxy> message_loop_; 61 scoped_refptr<base::MessageLoopProxy> message_loop_;
66
67 base::ScopedCFTypeRef<IOHIDDeviceRef> device_;
68 scoped_ptr<uint8_t, base::FreeDeleter> inbound_buffer_; 62 scoped_ptr<uint8_t, base::FreeDeleter> inbound_buffer_;
69 63
70 std::queue<PendingHidReport> pending_reports_;
71 std::queue<PendingHidRead> pending_reads_;
72
73 base::ThreadChecker thread_checker_;
74
75 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac); 64 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac);
76 }; 65 };
77 66
78
79 } // namespace device 67 } // namespace device
80 68
81 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_ 69 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698