#include "third_party/blink/renderer/modules/serial/serial_port.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_string_unsignedlong.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_serial_input_signals.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_serial_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_serial_output_signals.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_serial_port_info.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
#include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/modules/event_target_modules_names.h"
#include "third_party/blink/renderer/modules/serial/serial.h"
#include "third_party/blink/renderer/modules/serial/serial_port_underlying_sink.h"
#include "third_party/blink/renderer/modules/serial/serial_port_underlying_source.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
namespace {
SerialReceiveError;
SerialSendError;
const char kResourcesExhaustedReadBuffer[] = …;
const char kResourcesExhaustedWriteBuffer[] = …;
const char kNoSignals[] = …;
const char kPortClosed[] = …;
const char kOpenError[] = …;
const char kDeviceLostError[] = …;
const int kMaxBufferSize = …;
bool SendErrorIsFatal(SerialSendError error) { … }
bool ReceiveErrorIsFatal(SerialReceiveError error) { … }
}
SerialPort::SerialPort(Serial* parent, mojom::blink::SerialPortInfoPtr info)
: … { … }
SerialPort::~SerialPort() = default;
SerialPortInfo* SerialPort::getInfo() { … }
ScriptPromise<IDLUndefined> SerialPort::open(ScriptState* script_state,
const SerialOptions* options,
ExceptionState& exception_state) { … }
ReadableStream* SerialPort::readable(ScriptState* script_state,
ExceptionState& exception_state) { … }
WritableStream* SerialPort::writable(ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<SerialInputSignals> SerialPort::getSignals(
ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> SerialPort::setSignals(
ScriptState* script_state,
const SerialOutputSignals* signals,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> SerialPort::close(ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> SerialPort::forget(
ScriptState* script_state,
ExceptionState& exception_state) { … }
void SerialPort::AbortClose() { … }
void SerialPort::StreamsClosed() { … }
void SerialPort::Flush(
device::mojom::blink::SerialPortFlushMode mode,
device::mojom::blink::SerialPort::FlushCallback callback) { … }
void SerialPort::Drain(
device::mojom::blink::SerialPort::DrainCallback callback) { … }
void SerialPort::UnderlyingSourceClosed() { … }
void SerialPort::UnderlyingSinkClosed() { … }
void SerialPort::ContextDestroyed() { … }
void SerialPort::Trace(Visitor* visitor) const { … }
bool SerialPort::HasPendingActivity() const { … }
ExecutionContext* SerialPort::GetExecutionContext() const { … }
const AtomicString& SerialPort::InterfaceName() const { … }
DispatchEventResult SerialPort::DispatchEventInternal(Event& event) { … }
void SerialPort::OnReadError(device::mojom::blink::SerialReceiveError error) { … }
void SerialPort::OnSendError(device::mojom::blink::SerialSendError error) { … }
bool SerialPort::CreateDataPipe(mojo::ScopedDataPipeProducerHandle* producer,
mojo::ScopedDataPipeConsumerHandle* consumer) { … }
void SerialPort::OnConnectionError() { … }
void SerialPort::OnOpen(
mojo::PendingReceiver<device::mojom::blink::SerialPortClient>
client_receiver,
mojo::PendingRemote<device::mojom::blink::SerialPort> port) { … }
void SerialPort::OnGetSignals(
ScriptPromiseResolver<SerialInputSignals>* resolver,
device::mojom::blink::SerialPortControlSignalsPtr mojo_signals) { … }
void SerialPort::OnSetSignals(ScriptPromiseResolver<IDLUndefined>* resolver,
bool success) { … }
void SerialPort::OnClose() { … }
}