chromium/third_party/blink/renderer/modules/direct_sockets/tcp_socket.cc

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

#include "third_party/blink/renderer/modules/direct_sockets/tcp_socket.h"

#include "base/barrier_callback.h"
#include "base/metrics/histogram_functions.h"
#include "net/base/net_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_socket_dns_query_type.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_tcp_socket_open_info.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_tcp_socket_options.h"
#include "third_party/blink/renderer/core/dom/dom_exception.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/direct_sockets/stream_wrapper.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

namespace blink {

namespace {

constexpr char kTCPNetworkFailuresHistogramName[] =;

bool CheckSendReceiveBufferSize(const TCPSocketOptions* options,
                                ExceptionState& exception_state) {}

mojom::blink::DirectTCPSocketOptionsPtr CreateTCPSocketOptions(
    const String& remote_address,
    const uint16_t remote_port,
    const TCPSocketOptions* options,
    ExceptionState& exception_state) {}

}  // namespace

// static
TCPSocket* TCPSocket::Create(ScriptState* script_state,
                             const String& remoteAddress,
                             const uint16_t remotePort,
                             const TCPSocketOptions* options,
                             ExceptionState& exception_state) {}

// static
TCPSocket* TCPSocket::CreateFromAcceptedConnection(
    ScriptState* script_state,
    mojo::PendingRemote<network::mojom::blink::TCPConnectedSocket> tcp_socket,
    mojo::PendingReceiver<network::mojom::blink::SocketObserver>
        socket_observer,
    const net::IPEndPoint& peer_addr,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream) {}

TCPSocket::TCPSocket(ScriptState* script_state)
    :{}

TCPSocket::~TCPSocket() = default;

ScriptPromise<TCPSocketOpenInfo> TCPSocket::opened(
    ScriptState* script_state) const {}

ScriptPromise<IDLUndefined> TCPSocket::close(ScriptState*,
                                             ExceptionState& exception_state) {}

bool TCPSocket::Open(const String& remote_address,
                     const uint16_t remote_port,
                     const TCPSocketOptions* options,
                     ExceptionState& exception_state) {}

void TCPSocket::OnTCPSocketOpened(
    mojo::PendingRemote<network::mojom::blink::TCPConnectedSocket> tcp_socket,
    mojo::PendingReceiver<network::mojom::blink::SocketObserver>
        socket_observer,
    int32_t result,
    const std::optional<net::IPEndPoint>& local_addr,
    const std::optional<net::IPEndPoint>& peer_addr,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream) {}

void TCPSocket::FinishOpenOrAccept(
    mojo::PendingRemote<network::mojom::blink::TCPConnectedSocket> tcp_socket,
    mojo::PendingReceiver<network::mojom::blink::SocketObserver>
        socket_observer,
    const net::IPEndPoint& peer_addr,
    const std::optional<net::IPEndPoint>& local_addr,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream) {}

void TCPSocket::OnSocketConnectionError() {}

void TCPSocket::OnServiceConnectionError() {}

void TCPSocket::ReleaseResources() {}

void TCPSocket::OnReadError(int32_t net_error) {}

void TCPSocket::OnWriteError(int32_t net_error) {}

void TCPSocket::Trace(Visitor* visitor) const {}

bool TCPSocket::HasPendingActivity() const {}

void TCPSocket::ContextDestroyed() {}

void TCPSocket::OnBothStreamsClosed(std::vector<ScriptValue> args) {}

}  // namespace blink