| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_SERVICE_MAC_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_MAC_H_ |
| 6 #define DEVICE_HID_HID_SERVICE_MAC_H_ | 6 #define DEVICE_HID_HID_SERVICE_MAC_H_ |
| 7 | 7 |
| 8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
| 9 #include <IOKit/IOKitLib.h> | 9 #include <IOKit/IOKitLib.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/scoped_ioobject.h" | 14 #include "base/mac/scoped_ioobject.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "device/hid/hid_service.h" | 16 #include "device/hid/hid_service.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace device { | 22 namespace device { |
| 23 | 23 |
| 24 class HidConnection; | 24 class HidConnection; |
| 25 | 25 |
| 26 class HidServiceMac : public HidService { | 26 class HidServiceMac : public HidService { |
| 27 public: | 27 public: |
| 28 HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 28 HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 29 ~HidServiceMac() override; |
| 29 | 30 |
| 30 void Connect(const HidDeviceId& device_id, | 31 void Connect(const HidDeviceId& device_id, |
| 31 const ConnectCallback& connect) override; | 32 const ConnectCallback& connect) override; |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 ~HidServiceMac() override; | |
| 35 | |
| 36 // IOService matching callbacks. | 35 // IOService matching callbacks. |
| 37 static void FirstMatchCallback(void* context, io_iterator_t iterator); | 36 static void FirstMatchCallback(void* context, io_iterator_t iterator); |
| 38 static void TerminatedCallback(void* context, io_iterator_t iterator); | 37 static void TerminatedCallback(void* context, io_iterator_t iterator); |
| 39 | 38 |
| 40 void AddDevices(); | 39 void AddDevices(); |
| 41 void RemoveDevices(); | 40 void RemoveDevices(); |
| 42 | 41 |
| 43 static scoped_refptr<device::HidDeviceInfo> CreateDeviceInfo( | 42 static scoped_refptr<device::HidDeviceInfo> CreateDeviceInfo( |
| 44 io_service_t device); | 43 io_service_t device); |
| 45 | 44 |
| 46 // Platform notification port. | 45 // Platform notification port. |
| 47 IONotificationPortRef notify_port_; | 46 IONotificationPortRef notify_port_; |
| 48 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_; | 47 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_; |
| 49 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_; | 48 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_; |
| 50 | 49 |
| 51 // The task runner for the thread on which this service was created. | 50 // The task runner for the thread on which this service was created. |
| 52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 53 | 52 |
| 54 // The task runner for the FILE thread of the application using this service | 53 // The task runner for the FILE thread of the application using this service |
| 55 // on which slow running I/O operations can be performed. | 54 // on which slow running I/O operations can be performed. |
| 56 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 55 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 57 | 56 |
| 58 DISALLOW_COPY_AND_ASSIGN(HidServiceMac); | 57 DISALLOW_COPY_AND_ASSIGN(HidServiceMac); |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 } // namespace device | 60 } // namespace device |
| 62 | 61 |
| 63 #endif // DEVICE_HID_HID_SERVICE_MAC_H_ | 62 #endif // DEVICE_HID_HID_SERVICE_MAC_H_ |
| OLD | NEW |