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_SERVICE_MAC_H_
6 #define DEVICE_HID_HID_SERVICE_MAC_H_
12 #include "base/basictypes.h"
13 #include "base/mac/foundation_util.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/singleton.h"
16 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string16.h"
18 #include "base/synchronization/waitable_event.h"
19 #include "base/threading/thread.h"
20 #include "base/threading/thread_checker.h"
21 #include "build/build_config.h"
22 #include "device/hid/hid_device_info.h"
23 #include "device/hid/hid_service.h"
25 #include <CoreFoundation/CoreFoundation.h>
26 #include <IOKit/hid/IOHIDManager.h>
33 class HidServiceMac : public HidService {
37 virtual scoped_refptr<HidConnection> Connect(std::string device_id) OVERRIDE;
40 virtual ~HidServiceMac();
42 void ScheduleRunLoop();
43 void UnscheduleRunLoop();
45 // Device changing callbacks.
46 static void AddDeviceCallback(void* context,
50 static void RemoveDeviceCallback(void* context,
54 static HidServiceMac* InstanceFromContext(void* context);
56 IOHIDDeviceRef FindDevice(std::string id);
60 void PlatformAddDevice(IOHIDDeviceRef ref);
61 void PlatformRemoveDevice(IOHIDDeviceRef ref);
63 // The message loop this object belongs to.
64 scoped_refptr<base::MessageLoopProxy> message_loop_;
66 // Platform HID Manager
67 base::ScopedCFTypeRef<IOHIDManagerRef> hid_manager_ref_;
69 // Enumeration thread.
70 scoped_ptr<base::Thread> enumeration_runloop_thread_;
71 CFRunLoopRef enumeration_runloop_;
72 base::WaitableEvent enumeration_runloop_init_;
76 DISALLOW_COPY_AND_ASSIGN(HidServiceMac);
81 #endif // DEVICE_HID_HID_SERVICE_MAC_H_