Make castv2 performance test work.
[chromium-blink-merge.git] / device / hid / hid_connection_mac.h
blob7e6df0258806cbec760bc1f8937f0145c41c03e8
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.
5 #ifndef DEVICE_HID_HID_CONNECTION_MAC_H_
6 #define DEVICE_HID_HID_CONNECTION_MAC_H_
8 #include <CoreFoundation/CoreFoundation.h>
9 #include <IOKit/hid/IOHIDManager.h>
11 #include <queue>
13 #include "base/mac/foundation_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "device/hid/hid_connection.h"
17 namespace base {
18 class SingleThreadTaskRunner;
21 namespace net {
22 class IOBuffer;
25 namespace device {
27 class HidConnectionMac : public HidConnection {
28 public:
29 HidConnectionMac(
30 IOHIDDeviceRef device,
31 scoped_refptr<HidDeviceInfo> device_info,
32 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
34 private:
35 ~HidConnectionMac() override;
37 // HidConnection implementation.
38 void PlatformClose() override;
39 void PlatformRead(const ReadCallback& callback) override;
40 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
41 size_t size,
42 const WriteCallback& callback) override;
43 void PlatformGetFeatureReport(uint8_t report_id,
44 const ReadCallback& callback) override;
45 void PlatformSendFeatureReport(scoped_refptr<net::IOBuffer> buffer,
46 size_t size,
47 const WriteCallback& callback) override;
49 static void InputReportCallback(void* context,
50 IOReturn result,
51 void* sender,
52 IOHIDReportType type,
53 uint32_t report_id,
54 uint8_t* report_bytes,
55 CFIndex report_length);
56 void ProcessInputReport(scoped_refptr<net::IOBufferWithSize> buffer);
57 void ProcessReadQueue();
58 void GetFeatureReportAsync(uint8_t report_id, const ReadCallback& callback);
59 void SetReportAsync(IOHIDReportType report_type,
60 scoped_refptr<net::IOBuffer> buffer,
61 size_t size,
62 const WriteCallback& callback);
63 void ReturnAsyncResult(const base::Closure& callback);
65 base::ScopedCFTypeRef<IOHIDDeviceRef> device_;
66 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
67 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
68 std::vector<uint8_t> inbound_buffer_;
70 std::queue<PendingHidReport> pending_reports_;
71 std::queue<PendingHidRead> pending_reads_;
73 DISALLOW_COPY_AND_ASSIGN(HidConnectionMac);
76 } // namespace device
78 #endif // DEVICE_HID_HID_CONNECTION_MAC_H_