// 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. #ifndef IPCZ_SRC_IPCZ_ROUTER_H_ #define IPCZ_SRC_IPCZ_ROUTER_H_ #include <cstdint> #include <utility> #include "ipcz/fragment_ref.h" #include "ipcz/ipcz.h" #include "ipcz/parcel_queue.h" #include "ipcz/pending_transaction_set.h" #include "ipcz/route_edge.h" #include "ipcz/router_descriptor.h" #include "ipcz/router_link.h" #include "ipcz/sequence_number.h" #include "ipcz/sublink_id.h" #include "ipcz/trap_set.h" #include "third_party/abseil-cpp/absl/base/thread_annotations.h" #include "third_party/abseil-cpp/absl/synchronization/mutex.h" #include "util/ref_counted.h" namespace ipcz { class NodeLink; class RemoteRouterLink; struct RouterLinkState; class TrapEventDispatcher; // The Router is the main primitive responsible for routing parcels between ipcz // portals. This class is thread-safe. // // Before a Router can participate in any actual routing, it must have an // outward link to another Router (see SetOutwardLink()). To establish a locally // connected pair of Routers, pass both to LocalRouterLink::Create() and pass // each returned link to the coresponding router: // // Router::Pair routers = {MakeRefCounted<Router>(), // MakeRefCounted<Router>()}; // RouterLink::Pair links = // LocalRouterLink::CreatePair(LinkType::kCentral, routers); // routers.first->SetOutwardLink(std::move(links.first)); // routers.second->SetOutwardLink(std::move(links.second)); // // Each ipcz portal handle directly controls a terminal Router along its route, // and all routes stabilize to eventually consist of only two interconnected // terminal Routers. When a portal moves, its side of the route is extended by // creating a new terminal Router at the portal's new location. The previous // terminal Router remains as a proxying hop to be phased out eventually. class Router : public APIObjectImpl<Router, APIObject::kPortal> { … }; } // namespace ipcz #endif // IPCZ_SRC_IPCZ_ROUTER_H_