mojo: Introduce DirectReceiver

Experimental type which enables select use cases to establish Mojo
interface receiver that receives its IPCs directly on its binding thread
without a hop through the process's IO thread first.

This is not ever meant to be used widely and a more robust approach
could be to have Mojo manage thread-local node overrides, pending a
bunch of other changes that would be needed first.

For now this is defined so that Chrome developers can experiment with
specific use cases, like the renderer's input handler on its compositor
thread.

Bug: None
Change-Id: I11c7d6bc41bd2855541a98752f87e2420f1096fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4429594
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/main@{#1138821}
NOKEYCHECK=True
GitOrigin-RevId: 287f52543c2e20fcf6fb96e3d03b973e2dc14d80
diff --git a/src/ipcz/router.cc b/src/ipcz/router.cc
index ae68187..8035fa1 100644
--- a/src/ipcz/router.cc
+++ b/src/ipcz/router.cc
@@ -1447,8 +1447,21 @@
     decaying_inward_link->Deactivate();
   }
 
-  if (bridge_link && outward_link && !inward_link && !decaying_inward_link &&
-      !decaying_outward_link) {
+  // If we have an outward link, and we have no decaying outward link (or our
+  // decaying outward link has just finished decaying above), we consider the
+  // the outward link to be stable.
+  const bool has_stable_outward_link =
+      outward_link && (!decaying_outward_link || outward_link_decayed);
+
+  // If we have no primary inward link, and we have no decaying inward link
+  // (or our decaying inward link has just finished decaying above), this
+  // router has no inward-facing links.
+  const bool has_no_inward_links =
+      !inward_link && (!decaying_inward_link || inward_link_decayed);
+
+  // Bridge bypass is only possible with no inward links and a stable outward
+  // link.
+  if (bridge_link && has_stable_outward_link && has_no_inward_links) {
     MaybeStartBridgeBypass(context);
   }