blob: 3c868f8538de2bda42c11d3adfdc32e3cdf7961e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_
#define SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_
#include <IOKit/IOKitLib.h>
#include <map>
#include <utility>
#include "base/mac/scoped_ionotificationportref.h"
#include "base/mac/scoped_ioobject.h"
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "base/unguessable_token.h"
#include "services/device/serial/serial_device_enumerator.h"
namespace device {
// Discovers and enumerates serial devices available to the host.
class SerialDeviceEnumeratorMac : public SerialDeviceEnumerator {
public:
SerialDeviceEnumeratorMac();
SerialDeviceEnumeratorMac(const SerialDeviceEnumeratorMac&) = delete;
SerialDeviceEnumeratorMac& operator=(const SerialDeviceEnumeratorMac&) =
delete;
~SerialDeviceEnumeratorMac() override;
private:
static void FirstMatchCallback(void* context, io_iterator_t iterator);
static void TerminatedCallback(void* context, io_iterator_t iterator);
void AddDevices();
void RemoveDevices();
// Map from IORegistry entry IDs to the token used to refer to the device
// internally.
std::map<uint64_t, base::UnguessableToken> entries_;
base::mac::ScopedIONotificationPortRef notify_port_;
base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_;
base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_;
};
} // namespace device
#endif // SERVICES_DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_MAC_H_
|