1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_
6 #define SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_
8 #include <IOKit/IOKitLib.h>
13 #include "base/mac/scoped_ionotificationportref.h"
14 #include "base/mac/scoped_ioobject.h"
15 #include "base/sequence_checker.h"
16 #include "base/unguessable_token.h"
17 #include "services/device/serial/serial_device_enumerator.h"
21 // Discovers and enumerates serial devices available to the host.
22 class SerialDeviceEnumeratorMac : public SerialDeviceEnumerator {
24 SerialDeviceEnumeratorMac();
26 SerialDeviceEnumeratorMac(const SerialDeviceEnumeratorMac&) = delete;
27 SerialDeviceEnumeratorMac& operator=(const SerialDeviceEnumeratorMac&) =
30 ~SerialDeviceEnumeratorMac() override;
33 static void FirstMatchCallback(void* context, io_iterator_t iterator);
34 static void TerminatedCallback(void* context, io_iterator_t iterator);
39 // Map from IORegistry entry IDs to the token used to refer to the device
41 std::map<uint64_t, base::UnguessableToken> entries_;
43 base::mac::ScopedIONotificationPortRef notify_port_;
44 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_;
45 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_;
50 #endif // SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_