1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef DEVICE_HID_HID_SERVICE_MAC_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define DEVICE_HID_HID_SERVICE_MAC_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <CoreFoundation/CoreFoundation.h> 91675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch#include <IOKit/IOKitLib.h> 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string> 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/mac/foundation_util.h" 141675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch#include "base/mac/scoped_ioobject.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/ref_counted.h" 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "device/hid/hid_service.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace base { 191675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdochclass SingleThreadTaskRunner; 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace device { 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class HidConnection; 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class HidServiceMac : public HidService { 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 281675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id) 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) OVERRIDE; 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~HidServiceMac(); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 361675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch // IOService matching callbacks. 371675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch static void FirstMatchCallback(void* context, io_iterator_t iterator); 381675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch static void TerminatedCallback(void* context, io_iterator_t iterator); 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 401675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch void AddDevices(); 411675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch void RemoveDevices(); 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 431675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch // Platform notification port. 441675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch IONotificationPortRef notify_port_; 451675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_; 461675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 481675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch // The task runner for the thread on which this service was created. 491675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 511675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch // The task runner for the FILE thread of the application using this service 521675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch // on which slow running I/O operations can be performed. 531675a649fd7a8b3cb80ffddae2dc181f122353c5Ben Murdoch scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(HidServiceMac); 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace device 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // DEVICE_HID_HID_SERVICE_MAC_H_ 61