chromium/extensions/browser/api/serial/serial_connection.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/serial/serial_connection.h"

#include <algorithm>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/task/single_thread_task_runner.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/serial/serial_port_manager.h"
#include "extensions/common/api/serial.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/pending_remote.h"

namespace extensions {

namespace {

const int kDefaultBufferSize =;

api::serial::SendError ConvertSendErrorFromMojo(
    device::mojom::SerialSendError input) {}

api::serial::ReceiveError ConvertReceiveErrorFromMojo(
    device::mojom::SerialReceiveError input) {}

api::serial::DataBits ConvertDataBitsFromMojo(
    device::mojom::SerialDataBits input) {}

device::mojom::SerialDataBits ConvertDataBitsToMojo(
    api::serial::DataBits input) {}

api::serial::ParityBit ConvertParityBitFromMojo(
    device::mojom::SerialParityBit input) {}

device::mojom::SerialParityBit ConvertParityBitToMojo(
    api::serial::ParityBit input) {}

api::serial::StopBits ConvertStopBitsFromMojo(
    device::mojom::SerialStopBits input) {}

device::mojom::SerialStopBits ConvertStopBitsToMojo(
    api::serial::StopBits input) {}

}  // namespace

static base::LazyInstance<BrowserContextKeyedAPIFactory<
    ApiResourceManager<SerialConnection>>>::DestructorAtExit g_factory =;

// static
template <>
BrowserContextKeyedAPIFactory<ApiResourceManager<SerialConnection> >*
ApiResourceManager<SerialConnection>::GetFactoryInstance() {}

SerialConnection::SerialConnection(const std::string& owner_extension_id)
    :{}

SerialConnection::~SerialConnection() = default;

bool SerialConnection::IsPersistent() const {}

void SerialConnection::set_buffer_size(int buffer_size) {}

void SerialConnection::set_receive_timeout(int receive_timeout) {}

void SerialConnection::set_send_timeout(int send_timeout) {}

void SerialConnection::SetPaused(bool paused) {}

void SerialConnection::SetConnectionErrorHandler(
    base::OnceClosure connection_error_handler) {}

void SerialConnection::Open(api::SerialPortManager* port_manager,
                            const std::string& path,
                            const api::serial::ConnectionOptions& options,
                            OpenCompleteCallback callback) {}

void SerialConnection::CreatePipe(
    mojo::ScopedDataPipeProducerHandle* producer,
    mojo::ScopedDataPipeConsumerHandle* consumer) {}

void SerialConnection::SetUpReceiveDataPipe() {}

void SerialConnection::SetUpSendDataPipe() {}

void SerialConnection::OnReadError(device::mojom::SerialReceiveError error) {}

void SerialConnection::OnSendError(device::mojom::SerialSendError error) {}

void SerialConnection::OnOpen(
    mojo::PendingReceiver<device::mojom::SerialPortClient> client_receiver,
    OpenCompleteCallback callback,
    mojo::PendingRemote<device::mojom::SerialPort> serial_port) {}

void SerialConnection::OnReadPipeClosed() {}

void SerialConnection::OnReadPipeReadableOrClosed(
    MojoResult result,
    const mojo::HandleSignalsState& state) {}

void SerialConnection::StartPolling(const ReceiveEventCallback& callback) {}

void SerialConnection::Send(const std::vector<uint8_t>& data,
                            SendCompleteCallback callback) {}

void SerialConnection::Configure(const api::serial::ConnectionOptions& options,
                                 ConfigureCompleteCallback callback) {}

void SerialConnection::GetInfo(GetInfoCompleteCallback callback) const {}

void SerialConnection::Flush(device::mojom::SerialPortFlushMode mode,
                             FlushCompleteCallback callback) const {}

void SerialConnection::GetControlSignals(
    GetControlSignalsCompleteCallback callback) const {}

void SerialConnection::SetControlSignals(
    device::mojom::SerialHostControlSignalsPtr signals,
    SetControlSignalsCompleteCallback callback) {}

void SerialConnection::Close(base::OnceClosure callback) {}

void SerialConnection::InitSerialPortForTesting() {}

void SerialConnection::SetTimeoutCallback() {}

void SerialConnection::OnReceiveTimeout() {}

void SerialConnection::OnSendTimeout() {}

void SerialConnection::OnSendPipeWritableOrClosed(
    MojoResult result,
    const mojo::HandleSignalsState& state) {}

void SerialConnection::OnSendPipeClosed() {}

void SerialConnection::OnConnectionError() {}

void SerialConnection::OnClientReceiverClosed() {}

}  // namespace extensions

namespace mojo {

// static
device::mojom::SerialHostControlSignalsPtr
TypeConverter<device::mojom::SerialHostControlSignalsPtr,
              extensions::api::serial::HostControlSignals>::
    Convert(const extensions::api::serial::HostControlSignals& input) {}

// static
device::mojom::SerialConnectionOptionsPtr
TypeConverter<device::mojom::SerialConnectionOptionsPtr,
              extensions::api::serial::ConnectionOptions>::
    Convert(const extensions::api::serial::ConnectionOptions& input) {}

}  // namespace mojo