blob: e17d5a1175f5d6efd6c3ff5c9f0d9795a4a4357a [file] [log] [blame]
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ipcz/link_side.h"
#include "ipcz/router.h"
#include "ipcz/router_link.h"
#include "util/ref_counted.h"
namespace ipcz {
struct RouterLinkState;
// Local link between two Routers on the same node. This class is thread-safe.
// NOTE: This implementation must take caution when calling into any Router. See
// note on RouterLink's own class documentation.
class LocalRouterLink : public RouterLink {
// Creates a new pair of LocalRouterLinks linking the given pair of Routers
// together. The Routers must not currently have outward links. `type` must
// be either kCentral or kBridge, as local links may never be peripheral.
static RouterLink::Pair ConnectRouters(LinkType type,
const Router::Pair& routers);
// RouterLink:
LinkType GetType() const override;
RouterLinkState* GetLinkState() const override;
bool HasLocalPeer(const Router& router) override;
void AcceptParcel(Parcel& parcel) override;
void AcceptRouteClosure(SequenceNumber sequence_length) override;
void AcceptRouteDisconnected() override;
void MarkSideStable() override;
bool TryLockForBypass(const NodeName& bypass_request_source) override;
bool TryLockForClosure() override;
void Unlock() override;
bool FlushOtherSideIfWaiting() override;
bool CanNodeRequestBypass(const NodeName& bypass_request_source) override;
void BypassPeer(const NodeName& bypass_target_node,
SublinkId bypass_target_sublink) override;
void StopProxying(SequenceNumber inbound_sequence_length,
SequenceNumber outbound_sequence_length) override;
void ProxyWillStop(SequenceNumber inbound_sequence_length) override;
void BypassPeerWithLink(SublinkId new_sublink,
FragmentRef<RouterLinkState> new_link_state,
SequenceNumber inbound_sequence_length) override;
void StopProxyingToLocalPeer(
SequenceNumber outbound_sequence_length) override;
void Deactivate() override;
std::string Describe() const override;
class SharedState;
LocalRouterLink(LinkSide side, Ref<SharedState> state);
~LocalRouterLink() override;
const LinkSide side_;
const Ref<SharedState> state_;
} // namespace ipcz