chromium/third_party/ipcz/src/ipcz/node_connector.cc

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

#include "ipcz/node_connector.h"

#include <algorithm>
#include <utility>

#include "ipcz/driver_memory.h"
#include "ipcz/driver_transport.h"
#include "ipcz/ipcz.h"
#include "ipcz/link_side.h"
#include "ipcz/link_type.h"
#include "ipcz/node_link.h"
#include "ipcz/node_link_memory.h"
#include "ipcz/remote_router_link.h"
#include "ipcz/router.h"
#include "ipcz/sublink_id.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#include "util/log.h"
#include "util/ref_counted.h"

namespace ipcz {

namespace {

class NodeConnectorForBrokerToNonBroker : public NodeConnector {};

class NodeConnectorForNonBrokerToBroker : public NodeConnector {};

// Unlike other NodeConnectors, this one doesn't activate its transport or
// listen for any messages. Instead it uses an existing broker link to pass the
// transport along to a broker and wait for a reply to confirm either
// acceptance or rejection of the referral.
class NodeConnectorForReferrer : public NodeConnector {};

// A NodeConnector used by a referred node to await acceptance by the broker.
class NodeConnectorForReferredNonBroker : public NodeConnector {};

// The NodeConnector used by a broker to await a handshake from the referred
// node before responding to both that node and the referrer.
class NodeConnectorForBrokerReferral : public NodeConnector {};

class NodeConnectorForBrokerToBroker : public NodeConnector {};

std::pair<Ref<NodeConnector>, IpczResult> CreateConnector(
    Ref<Node> node,
    Ref<DriverTransport> transport,
    IpczConnectNodeFlags flags,
    const std::vector<Ref<Router>>& initial_routers,
    Ref<NodeLink> broker_link,
    NodeConnector::ConnectCallback callback) {}

}  // namespace

// static
IpczResult NodeConnector::ConnectNode(
    Ref<Node> node,
    Ref<DriverTransport> transport,
    IpczConnectNodeFlags flags,
    const std::vector<Ref<Router>>& initial_routers,
    ConnectCallback callback) {}

// static
bool NodeConnector::HandleNonBrokerReferral(
    Ref<Node> node,
    uint64_t referral_id,
    uint32_t num_initial_portals,
    Ref<NodeLink> referrer,
    Ref<DriverTransport> transport_to_referred_node,
    DriverMemoryWithMapping link_memory,
    DriverMemoryWithMapping client_link_memory) {}

NodeConnector::NodeConnector(Ref<Node> node,
                             Ref<DriverTransport> transport,
                             IpczConnectNodeFlags flags,
                             std::vector<Ref<Router>> waiting_routers,
                             ConnectCallback callback)
    :{}

NodeConnector::~NodeConnector() = default;

void NodeConnector::AcceptConnection(Node::Connection connection,
                                     uint32_t num_remote_portals) {}

void NodeConnector::RejectConnection() {}

bool NodeConnector::ActivateTransport() {}

void NodeConnector::EstablishWaitingRouters(Ref<NodeLink> to_link,
                                            size_t max_valid_portals) {}

void NodeConnector::OnTransportError() {}

}  // namespace ipcz