#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/device/serial/bluetooth_serial_port_impl.h"
#include <limits.h>
#include <algorithm>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/functional/callback_helpers.h"
#include "base/numerics/safe_conversions.h"
#include "components/device_event_log/device_event_log.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "net/base/io_buffer.h"
#include "services/device/public/cpp/bluetooth/bluetooth_utils.h"
#include "services/device/public/cpp/device_features.h"
namespace device {
void BluetoothSerialPortImpl::Open(
scoped_refptr<BluetoothAdapter> adapter,
const std::string& address,
const BluetoothUUID& service_class_id,
mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<mojom::SerialPortClient> client,
mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher,
OpenCallback callback) { … }
BluetoothSerialPortImpl::BluetoothSerialPortImpl(
scoped_refptr<BluetoothAdapter> adapter,
const std::string& address,
mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<mojom::SerialPortClient> client,
mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher)
: … { … }
BluetoothSerialPortImpl::~BluetoothSerialPortImpl() { … }
void BluetoothSerialPortImpl::OpenSocket(const BluetoothUUID& service_class_id,
OpenCallback callback) { … }
void BluetoothSerialPortImpl::OnSocketConnected(
scoped_refptr<BluetoothSocket> socket) { … }
void BluetoothSerialPortImpl::OnSocketConnectedError(
const std::string& message) { … }
void BluetoothSerialPortImpl::StartWriting(
mojo::ScopedDataPipeConsumerHandle consumer) { … }
void BluetoothSerialPortImpl::StartReading(
mojo::ScopedDataPipeProducerHandle producer) { … }
void BluetoothSerialPortImpl::ReadFromSocketAndWriteOut(
MojoResult result,
const mojo::HandleSignalsState& state) { … }
void BluetoothSerialPortImpl::ResetPendingWriteBuffer() { … }
void BluetoothSerialPortImpl::ResetReceiveBuffer() { … }
void BluetoothSerialPortImpl::ReadMore() { … }
void BluetoothSerialPortImpl::OnBluetoothSocketReceive(
int num_bytes_received,
scoped_refptr<net::IOBuffer> receive_buffer) { … }
void BluetoothSerialPortImpl::OnBluetoothSocketReceiveError(
BluetoothSocket::ErrorReason error_reason,
const std::string& error_message) { … }
void BluetoothSerialPortImpl::WriteToSocket(
MojoResult result,
const mojo::HandleSignalsState& state) { … }
void BluetoothSerialPortImpl::WriteMore() { … }
void BluetoothSerialPortImpl::OnBluetoothSocketSend(int num_bytes_sent) { … }
void BluetoothSerialPortImpl::OnBluetoothSocketSendError(
const std::string& error_message) { … }
void BluetoothSerialPortImpl::OnSocketDisconnected(CloseCallback callback) { … }
void BluetoothSerialPortImpl::Flush(mojom::SerialPortFlushMode mode,
FlushCallback callback) { … }
void BluetoothSerialPortImpl::Drain(DrainCallback callback) { … }
void BluetoothSerialPortImpl::GetControlSignals(
GetControlSignalsCallback callback) { … }
void BluetoothSerialPortImpl::SetControlSignals(
mojom::SerialHostControlSignalsPtr signals,
SetControlSignalsCallback callback) { … }
void BluetoothSerialPortImpl::ConfigurePort(
mojom::SerialConnectionOptionsPtr options,
ConfigurePortCallback callback) { … }
void BluetoothSerialPortImpl::GetPortInfo(GetPortInfoCallback callback) { … }
void BluetoothSerialPortImpl::Close(bool flush, CloseCallback callback) { … }
}