Upload upstream chromium 108.0.5359.1
[platform/framework/web/chromium-efl.git] / services / device / serial / fake_serial_device_enumerator.cc
1 // Copyright 2018 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.
4
5 #include "services/device/serial/fake_serial_device_enumerator.h"
6
7 #include <utility>
8
9
10 namespace device {
11
12 FakeSerialEnumerator::FakeSerialEnumerator() = default;
13
14 FakeSerialEnumerator::~FakeSerialEnumerator() = default;
15
16 void FakeSerialEnumerator::AddDevicePath(const base::FilePath& path) {
17   auto port = mojom::SerialPortInfo::New();
18   port->token = base::UnguessableToken::Create();
19   port->path = path;
20   paths_[path] = port->token;
21   AddPort(std::move(port));
22 }
23
24 void FakeSerialEnumerator::RemoveDevicePath(const base::FilePath& path) {
25   auto it = paths_.find(path);
26   DCHECK(it != paths_.end());
27   base::UnguessableToken token = it->second;
28   paths_.erase(it);
29   RemovePort(token);
30 }
31
32 }  // namespace device