#include "services/device/serial/serial_port_manager_impl.h"
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "services/device/public/cpp/device_features.h"
#include "services/device/serial/bluetooth_serial_device_enumerator.h"
#include "services/device/serial/bluetooth_serial_port_impl.h"
#include "services/device/serial/serial_device_enumerator.h"
#include "services/device/serial/serial_port_impl.h"
namespace device {
namespace {
void OnPortOpened(mojom::SerialPortManager::OpenPortCallback callback,
const scoped_refptr<base::TaskRunner>& task_runner,
mojo::PendingRemote<mojom::SerialPort> port) { … }
void FinishGetDevices(SerialPortManagerImpl::GetDevicesCallback callback,
std::vector<mojom::SerialPortInfoPtr> devices,
std::vector<mojom::SerialPortInfoPtr> bluetooth_devices) { … }
}
SerialPortManagerImpl::SerialPortManagerImpl(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
: … { … }
SerialPortManagerImpl::~SerialPortManagerImpl() { … }
void SerialPortManagerImpl::Bind(
mojo::PendingReceiver<mojom::SerialPortManager> receiver) { … }
void SerialPortManagerImpl::SetSerialEnumeratorForTesting(
std::unique_ptr<SerialDeviceEnumerator> fake_enumerator) { … }
void SerialPortManagerImpl::SetBluetoothSerialEnumeratorForTesting(
std::unique_ptr<BluetoothSerialDeviceEnumerator>
fake_bluetooth_enumerator) { … }
void SerialPortManagerImpl::SetClient(
mojo::PendingRemote<mojom::SerialPortManagerClient> client) { … }
void SerialPortManagerImpl::GetDevices(GetDevicesCallback callback) { … }
void SerialPortManagerImpl::OpenPort(
const base::UnguessableToken& token,
bool use_alternate_path,
device::mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<mojom::SerialPortClient> client,
mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher,
OpenPortCallback callback) { … }
void SerialPortManagerImpl::OpenBluetoothSerialPortOnUI(
const std::string& address,
const BluetoothUUID& service_class_id,
mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<mojom::SerialPortClient> client,
mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher,
BluetoothSerialPortImpl::OpenCallback callback) { … }
void SerialPortManagerImpl::OnPortAdded(const mojom::SerialPortInfo& port) { … }
void SerialPortManagerImpl::OnPortRemoved(const mojom::SerialPortInfo& port) { … }
void SerialPortManagerImpl::OnPortConnectedStateChanged(
const mojom::SerialPortInfo& port) { … }
}