Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / device / hid / hid_service_mac.h
blobf79c6e5ea8101e06d801635b8fa81b2ca70addc4
1 // Copyright 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_SERVICE_MAC_H_
6 #define DEVICE_HID_HID_SERVICE_MAC_H_
8 #include <CoreFoundation/CoreFoundation.h>
9 #include <IOKit/IOKitLib.h>
11 #include <string>
13 #include "base/mac/foundation_util.h"
14 #include "base/mac/scoped_ioobject.h"
15 #include "base/memory/ref_counted.h"
16 #include "device/hid/hid_service.h"
18 namespace base {
19 class SingleThreadTaskRunner;
22 namespace device {
24 class HidConnection;
26 class HidServiceMac : public HidService {
27 public:
28 HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
29 ~HidServiceMac() override;
31 void Connect(const HidDeviceId& device_id,
32 const ConnectCallback& connect) override;
34 private:
35 // IOService matching callbacks.
36 static void FirstMatchCallback(void* context, io_iterator_t iterator);
37 static void TerminatedCallback(void* context, io_iterator_t iterator);
39 void AddDevices();
40 void RemoveDevices();
42 static scoped_refptr<device::HidDeviceInfo> CreateDeviceInfo(
43 io_service_t device);
45 // Platform notification port.
46 IONotificationPortRef notify_port_;
47 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_;
48 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_;
50 // The task runner for the thread on which this service was created.
51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
53 // The task runner for the FILE thread of the application using this service
54 // on which slow running I/O operations can be performed.
55 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
57 DISALLOW_COPY_AND_ASSIGN(HidServiceMac);
60 } // namespace device
62 #endif // DEVICE_HID_HID_SERVICE_MAC_H_