ipcz: Remove support for remote portal feedback

Some trap conditions (e.g. IPCZ_TRAP_ABOVE_MAX_REMOTE_PARCELS) and other
API features (e.g. IpczPutLimits) require monitoring of remote portal
state in order to function. This monitoring is no longer implemented in
ipcz, so the relevant API features are defunct.

This removes those features from the ipcz ABI for v1 stabilization.
They may be added back in a future version, though probably not in the
same form.

Fixed: 1450338
Change-Id: Ie9bdbb3d328df8fed7bb9bc77555aa4c7d97225e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4581209
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1152126}
NOKEYCHECK=True
GitOrigin-RevId: a6a98e0181d82afc17bbd05501c76d7601bd56f5
diff --git a/include/ipcz/ipcz.h b/include/ipcz/ipcz.h
index b172df7..6f24302 100644
--- a/include/ipcz/ipcz.h
+++ b/include/ipcz/ipcz.h
@@ -622,59 +622,16 @@
 // the connecting node will be delegated to the connectee.
 #define IPCZ_CONNECT_NODE_TO_ALLOCATION_DELEGATE IPCZ_FLAG_BIT(3)
 
-// Optional limits provided by IpczPutOptions for Put() or IpczBeginPutOptions
-// for BeginPut().
-struct IPCZ_ALIGN(8) IpczPutLimits {
-  // The exact size of this structure in bytes. Must be set accurately before
-  // passing the structure to any API functions.
-  size_t size;
-
-  // Specifies the maximum number of unread parcels to allow in a portal's
-  // queue. If a Put() or BeginPut() call specifying this limit would cause the
-  // receiver's number of number of queued unread parcels to exceed this value,
-  // the call will fail with IPCZ_RESULT_RESOURCE_EXHAUSTED.
-  size_t max_queued_parcels;
-
-  // Specifies the maximum number of data bytes to allow in a portal's queue.
-  // If a Put() or BeginPut() call specifying this limit would cause the number
-  // of data bytes across all queued unread parcels to exceed this value, the
-  // call will fail with IPCZ_RESULT_RESOURCE_EXHAUSTED.
-  size_t max_queued_bytes;
-};
-
-// Options given to Put() to modify its default behavior.
-struct IPCZ_ALIGN(8) IpczPutOptions {
-  // The exact size of this structure in bytes. Must be set accurately before
-  // passing the structure to Put().
-  size_t size;
-
-  // Optional limits to apply when determining if the Put() should be completed.
-  const struct IpczPutLimits* limits;
-};
-
 // See BeginPut() and the IPCZ_BEGIN_PUT_* flags described below.
 typedef uint32_t IpczBeginPutFlags;
 
 // Indicates that the caller is willing to produce less data than originally
 // requested by their `*num_bytes` argument to BeginPut(). If the implementation
-// would prefer a smaller chunk of data or if the requested size would exceed
-// limits specified in the call's corresponding IpczPutLimits, passing this flag
-// may allow the call to succeed while returning a smaller acceptable value in
-// `*num_bytes`, rather than simply failing the call with
-// IPCZ_RESULT_RESOURCE_EXHAUSTED.
+// would prefer a smaller chunk of data, passing this flag may allow the call to
+// succeed while returning a smaller acceptable value in `*num_bytes`, rather
+// than simply failing the call with IPCZ_RESULT_RESOURCE_EXHAUSTED.
 #define IPCZ_BEGIN_PUT_ALLOW_PARTIAL IPCZ_FLAG_BIT(0)
 
-// Options given to BeginPut() to modify its default behavior.
-struct IPCZ_ALIGN(8) IpczBeginPutOptions {
-  // The exact size of this structure in bytes. Must be set accurately before
-  // passing the structure to BeginPut().
-  size_t size;
-
-  // Optional limits to apply when determining if the BeginPut() should be
-  // completed.
-  const struct IpczPutLimits* limits;
-};
-
 // See EndPut() and the IPCZ_END_PUT_* flags described below.
 typedef uint32_t IpczEndPutFlags;
 
@@ -820,13 +777,6 @@
   // The number of unretrieved bytes (across all unretrieved parcels) queued on
   // this portal.
   size_t num_local_bytes;
-
-  // The number of unretrieved parcels queued on the opposite portal.
-  size_t num_remote_parcels;
-
-  // The number of unretrieved bytes (across all unretrieved parcels) queued on
-  // the opposite portal.
-  size_t num_remote_bytes;
 };
 
 // Flags given to IpczTrapConditions to indicate which types of conditions a
@@ -871,24 +821,10 @@
 // IpczTrapConditions. Level-triggered.
 #define IPCZ_TRAP_ABOVE_MIN_LOCAL_BYTES IPCZ_FLAG_BIT(4)
 
-// Triggers a trap event whenever the number of parcels queued for retrieval on
-// the opposite portal drops below the threshold given by `max_remote_parcels`
-// IpczTrapConditions. Level-triggered.
-#define IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS IPCZ_FLAG_BIT(5)
-
-// Triggers a trap event whenever the number of bytes queued for retrieval on
-// the opposite portal drops below the threshold given by `max_remote_bytes` in
-// IpczTrapConditions. Level-triggered.
-#define IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES IPCZ_FLAG_BIT(6)
-
 // Triggers a trap event whenever the number of locally available parcels
 // increases by any amount. Edge-triggered.
 #define IPCZ_TRAP_NEW_LOCAL_PARCEL IPCZ_FLAG_BIT(7)
 
-// Triggers a trap event whenever the number of queued remote parcels decreases
-// by any amount. Edge-triggered.
-#define IPCZ_TRAP_CONSUMED_REMOTE_PARCEL IPCZ_FLAG_BIT(8)
-
 // Indicates that the trap event is being fired from within the extent of an
 // ipcz API call (i.e., as opposed to being fired from within the extent of an
 // incoming driver transport notification.) For example if a trap is monitoring
@@ -918,14 +854,6 @@
   // See IPCZ_TRAP_ABOVE_MIN_LOCAL_BYTES. If that flag is not set in `flags`,
   // this field is ignored.
   size_t min_local_bytes;
-
-  // See IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS. If that flag is not set in `flags`,
-  // this field is ignored.
-  size_t max_remote_parcels;
-
-  // See IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES. If that flag is not set in `flags`,
-  // this field is ignored.
-  size_t max_remote_bytes;
 };
 
 // Structure passed to each IpczTrapEventHandler invocation with details about
@@ -1251,8 +1179,6 @@
   //
   // `flags` is unused and must be IPCZ_NO_FLAGS.
   //
-  // `options` may be null.
-  //
   // If this call fails (returning anything other than IPCZ_RESULT_OK), any
   // provided handles remain property of the caller. If it succeeds, their
   // ownership is assumed by ipcz.
@@ -1265,6 +1191,8 @@
   // writing. In such cases, a two-phase put operation can be used instead, by
   // calling BeginPut() and EndPut() as defined below.
   //
+  // `options` is ignored and must be null.
+  //
   // Returns:
   //
   //    IPCZ_RESULT_OK if the provided data and handles were successfully placed
@@ -1272,24 +1200,19 @@
   //
   //    IPCZ_RESULT_INVALID_ARGUMENT if `portal` is invalid, `data` is null but
   //        `num_bytes` is non-zero, `handles` is null but `num_handles` is
-  //        non-zero, `options` is non-null but invalid, one of the handles in
-  //        `handles` is equal to `portal` or its (local) opposite if
-  //        applicable, or if any handle in `handles` is invalid or not
-  //        serializable.
-  //
-  //    IPCZ_RESULT_RESOURCE_EXHAUSTED if `options->limits` is non-null and at
-  //        least one of the specified limits would be violated by the
-  //        successful completion of this call.
+  //        non-zero, one of the handles in `handles` is equal to `portal` or
+  //        its (local) opposite if applicable, or if any handle in `handles` is
+  //        invalid or not serializable.
   //
   //    IPCZ_RESULT_NOT_FOUND if it is known that the opposite portal has
   //        already been closed and anything put into this portal would be lost.
-  IpczResult(IPCZ_API* Put)(IpczHandle portal,                      // in
-                            const void* data,                       // in
-                            size_t num_bytes,                       // in
-                            const IpczHandle* handles,              // in
-                            size_t num_handles,                     // in
-                            uint32_t flags,                         // in
-                            const struct IpczPutOptions* options);  // in
+  IpczResult(IPCZ_API* Put)(IpczHandle portal,          // in
+                            const void* data,           // in
+                            size_t num_bytes,           // in
+                            const IpczHandle* handles,  // in
+                            size_t num_handles,         // in
+                            uint32_t flags,             // in
+                            const void* options);       // in
 
   // BeginPut()
   // ==========
@@ -1304,17 +1227,16 @@
   // of `*num_bytes` conveys the actual capacity available for writing at
   // `data`.
   //
-  // Limits provided to BeginPut() elicit similar behavior to Put(), with the
-  // exception that `flags` may specify IPCZ_BEGIN_PUT_ALLOW_PARTIAL to allow
-  // BeginPut() to succeed even the caller's suggested value of
-  // `*num_bytes` would cause the portal to exceed the maximum queued byte limit
-  // given by `options->limits`. In that case BeginPut() may update `*num_bytes`
-  // to reflect the remaining capacity of the portal, allowing the caller to
-  // commit at least some portion of their data with EndPut().
+  // `flags` may specify IPCZ_BEGIN_PUT_ALLOW_PARTIAL to allow the
+  // implementation to select a smaller data size than the input value of
+  // `*num_bytes` if it might have a good reason to do so (e.g. performance or
+  // resource limitations).
   //
   // Handles to transmit within a two-phase put are provided when committing the
   // operation with EndPut().
   //
+  // `options` is ignored and must be null.
+  //
   // Returns:
   //
   //    IPCZ_RESULT_OK if the two-phase put operation has been successfully
@@ -1325,8 +1247,7 @@
   //        set in `flags`) the capacity requested by the input value of
   //        `*num_bytes`.
   //
-  //    IPCZ_RESULT_INVALID_ARGUMENT if `portal` is invalid, `data` is null, or
-  //        options is non-null but invalid.
+  //    IPCZ_RESULT_INVALID_ARGUMENT if `portal` is invalid or `data` is null.
   //
   //    IPCZ_RESULT_RESOURCE_EXHAUSTED if completing the put with the number of
   //        bytes specified by `*num_bytes` would cause the portal to exceed the
@@ -1336,12 +1257,11 @@
   //
   //    IPCZ_RESULT_NOT_FOUND if it is known that the opposite portal has
   //        already been closed and anything put into this portal would be lost.
-  IpczResult(IPCZ_API* BeginPut)(
-      IpczHandle portal,                          // in
-      IpczBeginPutFlags flags,                    // in
-      const struct IpczBeginPutOptions* options,  // in
-      size_t* num_bytes,                          // in/out
-      void** data);                               // out
+  IpczResult(IPCZ_API* BeginPut)(IpczHandle portal,        // in
+                                 IpczBeginPutFlags flags,  // in
+                                 const void* options,      // in
+                                 size_t* num_bytes,        // in/out
+                                 void** data);             // out
 
   // EndPut()
   // ========
diff --git a/src/BUILD.gn b/src/BUILD.gn
index 75928d5..3af9916 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -389,7 +389,6 @@
     "ipcz/sequenced_queue_test.cc",
     "merge_portals_test.cc",
     "parcel_test.cc",
-    "queueing_test.cc",
     "reference_drivers/sync_reference_driver_test.cc",
     "remote_portal_test.cc",
     "trap_test.cc",
diff --git a/src/api.cc b/src/api.cc
index 9b618a7..417e76e 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -154,40 +154,31 @@
                const IpczHandle* handles,
                size_t num_handles,
                uint32_t flags,
-               const IpczPutOptions* options) {
+               const void* options) {
   ipcz::Portal* portal = ipcz::Portal::FromHandle(portal_handle);
   if (!portal) {
     return IPCZ_RESULT_INVALID_ARGUMENT;
   }
   return portal->Put(
       absl::MakeSpan(static_cast<const uint8_t*>(data), num_bytes),
-      absl::MakeSpan(handles, num_handles),
-      options ? options->limits : nullptr);
+      absl::MakeSpan(handles, num_handles));
 }
 
 IpczResult BeginPut(IpczHandle portal_handle,
                     IpczBeginPutFlags flags,
-                    const IpczBeginPutOptions* options,
+                    const void* options,
                     size_t* num_bytes,
                     void** data) {
   ipcz::Portal* portal = ipcz::Portal::FromHandle(portal_handle);
   if (!portal || !data) {
     return IPCZ_RESULT_INVALID_ARGUMENT;
   }
-  if (options && options->size < sizeof(IpczBeginPutOptions)) {
-    return IPCZ_RESULT_INVALID_ARGUMENT;
-  }
-
-  const IpczPutLimits* limits = options ? options->limits : nullptr;
-  if (limits && limits->size < sizeof(IpczPutLimits)) {
-    return IPCZ_RESULT_INVALID_ARGUMENT;
-  }
 
   size_t dummy_num_bytes = 0;
   if (!num_bytes) {
     num_bytes = &dummy_num_bytes;
   }
-  return portal->BeginPut(flags, limits, *num_bytes, *data);
+  return portal->BeginPut(flags, *num_bytes, *data);
 }
 
 IpczResult EndPut(IpczHandle portal_handle,
diff --git a/src/api_test.cc b/src/api_test.cc
index 5b7548b..1636f69 100644
--- a/src/api_test.cc
+++ b/src/api_test.cc
@@ -156,8 +156,6 @@
   EXPECT_EQ(0u, status.flags & IPCZ_PORTAL_STATUS_DEAD);
   EXPECT_EQ(0u, status.num_local_parcels);
   EXPECT_EQ(0u, status.num_local_bytes);
-  EXPECT_EQ(0u, status.num_remote_parcels);
-  EXPECT_EQ(0u, status.num_remote_bytes);
 
   Close(b);
   EXPECT_EQ(IPCZ_RESULT_OK,
@@ -338,11 +336,6 @@
   EXPECT_EQ(IPCZ_RESULT_INVALID_ARGUMENT,
             ipcz().BeginPut(a, IPCZ_NO_FLAGS, nullptr, &num_bytes, nullptr));
 
-  // Invalid options.
-  IpczBeginPutOptions options = {.size = 0};
-  EXPECT_EQ(IPCZ_RESULT_INVALID_ARGUMENT,
-            ipcz().BeginPut(a, IPCZ_NO_FLAGS, &options, &num_bytes, &data));
-
   // Start a put transaction to test EndPut().
   EXPECT_EQ(IPCZ_RESULT_OK,
             ipcz().BeginPut(a, IPCZ_NO_FLAGS, nullptr, &num_bytes, &data));
diff --git a/src/ipcz/portal.cc b/src/ipcz/portal.cc
index c4b5015..d9a5b3b 100644
--- a/src/ipcz/portal.cc
+++ b/src/ipcz/portal.cc
@@ -78,8 +78,7 @@
 }
 
 IpczResult Portal::Put(absl::Span<const uint8_t> data,
-                       absl::Span<const IpczHandle> handles,
-                       const IpczPutLimits* limits) {
+                       absl::Span<const IpczHandle> handles) {
   std::vector<Ref<APIObject>> objects;
   if (!ValidateAndAcquireObjectsForTransitFrom(*this, handles, objects)) {
     return IPCZ_RESULT_INVALID_ARGUMENT;
@@ -89,10 +88,6 @@
     return IPCZ_RESULT_NOT_FOUND;
   }
 
-  if (limits && router_->GetOutboundCapacityInBytes(*limits) < data.size()) {
-    return IPCZ_RESULT_RESOURCE_EXHAUSTED;
-  }
-
   Parcel parcel;
   const IpczResult allocate_result = router_->AllocateOutboundParcel(
       data.size(), /*allow_partial=*/false, parcel);
@@ -118,20 +113,9 @@
 }
 
 IpczResult Portal::BeginPut(IpczBeginPutFlags flags,
-                            const IpczPutLimits* limits,
                             size_t& num_data_bytes,
                             void*& data) {
   const bool allow_partial = (flags & IPCZ_BEGIN_PUT_ALLOW_PARTIAL) != 0;
-  if (limits) {
-    size_t max_num_data_bytes = router_->GetOutboundCapacityInBytes(*limits);
-    if (max_num_data_bytes < num_data_bytes) {
-      num_data_bytes = max_num_data_bytes;
-      if (!allow_partial || max_num_data_bytes == 0) {
-        return IPCZ_RESULT_RESOURCE_EXHAUSTED;
-      }
-    }
-  }
-
   if (router_->IsPeerClosed()) {
     return IPCZ_RESULT_NOT_FOUND;
   }
diff --git a/src/ipcz/portal.h b/src/ipcz/portal.h
index 174c640..4fd064e 100644
--- a/src/ipcz/portal.h
+++ b/src/ipcz/portal.h
@@ -49,10 +49,8 @@
   IpczResult Merge(Portal& other);
 
   IpczResult Put(absl::Span<const uint8_t> data,
-                 absl::Span<const IpczHandle> handles,
-                 const IpczPutLimits* limits);
+                 absl::Span<const IpczHandle> handles);
   IpczResult BeginPut(IpczBeginPutFlags flags,
-                      const IpczPutLimits* limits,
                       size_t& num_data_bytes,
                       void*& data);
   IpczResult CommitPut(const void* data,
diff --git a/src/ipcz/router.cc b/src/ipcz/router.cc
index 8035fa1..77263bb 100644
--- a/src/ipcz/router.cc
+++ b/src/ipcz/router.cc
@@ -205,33 +205,6 @@
   Flush(context, kForceProxyBypassAttempt);
 }
 
-size_t Router::GetOutboundCapacityInBytes(const IpczPutLimits& limits) {
-  if (limits.max_queued_bytes == 0 || limits.max_queued_parcels == 0) {
-    return 0;
-  }
-
-  const OperationContext context{OperationContext::kAPICall};
-  absl::MutexLock lock(&mutex_);
-  if (status_.num_remote_parcels >= limits.max_queued_parcels ||
-      status_.num_remote_bytes >= limits.max_queued_bytes) {
-    return 0;
-  }
-
-  if (outbound_parcels_.GetNumAvailableElements() >=
-      limits.max_queued_parcels - status_.num_remote_parcels) {
-    return 0;
-  }
-
-  const size_t num_bytes_pending =
-      outbound_parcels_.GetTotalAvailableElementSize();
-  const size_t available_capacity =
-      limits.max_queued_bytes - status_.num_remote_bytes;
-  if (num_bytes_pending >= available_capacity) {
-    return 0;
-  }
-  return available_capacity - num_bytes_pending;
-}
-
 bool Router::AcceptInboundParcel(const OperationContext& context,
                                  Parcel& parcel) {
   TrapEventDispatcher dispatcher;
@@ -309,8 +282,6 @@
           status_.flags |=
               IPCZ_PORTAL_STATUS_PEER_CLOSED | IPCZ_PORTAL_STATUS_DEAD;
         }
-        status_.num_remote_bytes = 0;
-        status_.num_remote_parcels = 0;
         traps_.UpdatePortalStatus(
             context, status_, TrapSet::UpdateReason::kPeerClosed, dispatcher);
       }
@@ -366,8 +337,6 @@
         status_.flags |=
             IPCZ_PORTAL_STATUS_PEER_CLOSED | IPCZ_PORTAL_STATUS_DEAD;
       }
-      status_.num_remote_parcels = 0;
-      status_.num_remote_bytes = 0;
       traps_.UpdatePortalStatus(context, status_,
                                 TrapSet::UpdateReason::kPeerClosed, dispatcher);
     }
@@ -599,8 +568,6 @@
         descriptor.num_bytes_consumed);
     if (descriptor.peer_closed) {
       router->is_peer_closed_ = true;
-      router->status_.num_remote_parcels = 0;
-      router->status_.num_remote_bytes = 0;
       if (!router->inbound_parcels_.SetFinalSequenceLength(
               descriptor.closed_peer_sequence_length)) {
         return nullptr;
diff --git a/src/ipcz/router.h b/src/ipcz/router.h
index 28d1633..6d8cdd5 100644
--- a/src/ipcz/router.h
+++ b/src/ipcz/router.h
@@ -109,16 +109,6 @@
   void SetOutwardLink(const OperationContext& context,
                       const Ref<RouterLink> link);
 
-  // Returns a best-effort estimation of the maximum parcel size (in bytes) that
-  // can be sent outward from this router without the receiving portal exceeding
-  // any of the specified `limits`.
-  size_t GetOutboundCapacityInBytes(const IpczPutLimits& limits);
-
-  // Returns the maximum inbound parcel size (in bytes) that can be accepted by
-  // this router's inbound parcel queue without that queue exceeding any of the
-  // specified `limits`.
-  size_t GetInboundCapacityInBytes(const IpczPutLimits& limits);
-
   // Accepts an inbound parcel from the outward edge of this router, either to
   // queue it for retrieval or forward it further inward. `source` indicates
   // whether the parcel is arriving as a direct result of some local ipcz API
diff --git a/src/ipcz/trap_set.cc b/src/ipcz/trap_set.cc
index c0d26cd..c0619d5 100644
--- a/src/ipcz/trap_set.cc
+++ b/src/ipcz/trap_set.cc
@@ -37,14 +37,6 @@
       status.num_local_bytes > conditions.min_local_bytes) {
     event_flags |= IPCZ_TRAP_ABOVE_MIN_LOCAL_BYTES;
   }
-  if ((conditions.flags & IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS) &&
-      status.num_remote_parcels < conditions.max_remote_parcels) {
-    event_flags |= IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS;
-  }
-  if ((conditions.flags & IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES) &&
-      status.num_remote_bytes < conditions.max_remote_bytes) {
-    event_flags |= IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES;
-  }
   if ((conditions.flags & IPCZ_TRAP_NEW_LOCAL_PARCEL) &&
       reason == TrapSet::UpdateReason::kNewLocalParcel) {
     event_flags |= IPCZ_TRAP_NEW_LOCAL_PARCEL;
@@ -52,14 +44,6 @@
   return event_flags;
 }
 
-bool NeedRemoteParcels(IpczTrapConditionFlags flags) {
-  return (flags & IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS) != 0;
-}
-
-bool NeedRemoteBytes(IpczTrapConditionFlags flags) {
-  return (flags & IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES) != 0;
-}
-
 }  // namespace
 
 TrapSet::TrapSet() = default;
@@ -102,12 +86,6 @@
   }
 
   traps_.emplace_back(conditions, handler, context);
-  if (NeedRemoteParcels(conditions.flags)) {
-    ++num_traps_monitoring_remote_parcels_;
-  }
-  if (NeedRemoteBytes(conditions.flags)) {
-    ++num_traps_monitoring_remote_bytes_;
-  }
   return IPCZ_RESULT_OK;
 }
 
@@ -130,12 +108,6 @@
     }
     dispatcher.DeferEvent(trap.handler, trap.context, flags, status);
     it = traps_.erase(it);
-    if (NeedRemoteParcels(flags)) {
-      --num_traps_monitoring_remote_parcels_;
-    }
-    if (NeedRemoteBytes(flags)) {
-      --num_traps_monitoring_remote_bytes_;
-    }
   }
 }
 
@@ -150,8 +122,6 @@
                           last_known_status_);
   }
   traps_.clear();
-  num_traps_monitoring_remote_parcels_ = 0;
-  num_traps_monitoring_remote_bytes_ = 0;
 }
 
 TrapSet::Trap::Trap(IpczTrapConditions conditions,
diff --git a/src/ipcz/trap_set.h b/src/ipcz/trap_set.h
index a772796..7a341c8 100644
--- a/src/ipcz/trap_set.h
+++ b/src/ipcz/trap_set.h
@@ -34,11 +34,6 @@
     // A previously queued inbound parcel has been fully or partially retrieved
     // by the application.
     kLocalParcelConsumed,
-
-    // A remote peer has changed state in a way that may be interesting to a
-    // trap in the set; for example, parcels may have been consumed from the
-    // remote queue.
-    kRemoteActivity,
   };
 
   TrapSet();
@@ -50,18 +45,6 @@
 
   bool empty() const { return traps_.empty(); }
 
-  // Indicates whether any installed traps in this set require monitoring of
-  // remote queue state.
-  bool need_remote_parcels() const {
-    return num_traps_monitoring_remote_parcels_ > 0;
-  }
-  bool need_remote_bytes() const {
-    return num_traps_monitoring_remote_bytes_ > 0;
-  }
-  bool need_remote_state() const {
-    return need_remote_parcels() || need_remote_bytes();
-  }
-
   // Returns the set of trap condition flags within `conditions` that would be
   // raised right now if a trap were installed to watch for them, given
   // `current_status` as the status of the portal being watched. If this returns
@@ -110,8 +93,6 @@
 
   using TrapList = absl::InlinedVector<Trap, 4>;
   TrapList traps_;
-  size_t num_traps_monitoring_remote_parcels_ = 0;
-  size_t num_traps_monitoring_remote_bytes_ = 0;
   IpczPortalStatus last_known_status_ = {.size = sizeof(last_known_status_)};
 };
 
diff --git a/src/queueing_test.cc b/src/queueing_test.cc
deleted file mode 100644
index 089e9df..0000000
--- a/src/queueing_test.cc
+++ /dev/null
@@ -1,275 +0,0 @@
-// 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 <limits>
-#include <string>
-
-#include "ipcz/ipcz.h"
-#include "test/multinode_test.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/synchronization/notification.h"
-
-namespace ipcz {
-namespace {
-
-using QueueingTestNode = test::TestNode;
-using QueueingTest = test::MultinodeTest<QueueingTestNode>;
-
-MULTINODE_TEST_NODE(QueueingTestNode, RemoteQueueFeedbackClient) {
-  IpczHandle b = ConnectToBroker();
-
-  // Wait for the first parcel to arrive.
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            WaitForConditions(b, {.flags = IPCZ_TRAP_ABOVE_MIN_LOCAL_PARCELS,
-                                  .min_local_parcels = 0}));
-
-  // Send and ack and wait for another parcel to arrive.
-  absl::Notification new_parcel_arrived;
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            Trap(b, {.flags = IPCZ_TRAP_NEW_LOCAL_PARCEL},
-                 [&](const IpczTrapEvent&) { new_parcel_arrived.Notify(); }));
-  EXPECT_EQ(IPCZ_RESULT_OK, Put(b, "ok"));
-  new_parcel_arrived.WaitForNotification();
-
-  std::string data;
-  EXPECT_EQ(IPCZ_RESULT_OK, Get(b, &data));
-  EXPECT_EQ("1234", data);
-
-  std::string ack;
-  EXPECT_EQ(IPCZ_RESULT_OK, WaitToGet(b, &ack));
-  EXPECT_EQ("ok", ack);
-
-  EXPECT_EQ(IPCZ_RESULT_OK, WaitForConditionFlags(b, IPCZ_TRAP_PEER_CLOSED));
-  Close(b);
-}
-
-// Disabled because remote queue state monitoring has been temporarily dropped
-// from ipcz to improve performance. See https://crbug.com/1383754.
-MULTINODE_TEST(QueueingTest, DISABLED_RemoteQueueFeedback) {
-  // Exercises operations which rely on feedback from the remote peer regarding
-  // its inbound parcel queue state.
-  IpczHandle c = SpawnTestNode<RemoteQueueFeedbackClient>();
-
-  // This trap can only be set while the remote portal appears to be non-empty.
-  const IpczTrapConditions all_bytes_consumed = {
-      .size = sizeof(all_bytes_consumed),
-      .flags = IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES,
-      .max_remote_bytes = 1,
-  };
-  EXPECT_EQ(IPCZ_RESULT_FAILED_PRECONDITION,
-            Trap(c, all_bytes_consumed, [&](const auto&) {}));
-
-  // Send 4 bytes and wait for acknowledgement that the parcel was received.
-  std::string ack;
-  EXPECT_EQ(IPCZ_RESULT_OK, Put(c, "1234"));
-  EXPECT_EQ(IPCZ_RESULT_OK, WaitToGet(c, &ack));
-  EXPECT_EQ("ok", ack);
-
-  // Now these operations should always fail due to the specified limits.
-  EXPECT_EQ(IPCZ_RESULT_RESOURCE_EXHAUSTED,
-            PutWithLimits(c, {.max_queued_parcels = 1}, "meh"));
-  EXPECT_EQ(IPCZ_RESULT_RESOURCE_EXHAUSTED,
-            PutWithLimits(c, {.max_queued_bytes = 4}, "?"));
-
-  // Now we should be able to install traps for both queued parcels and bytes on
-  // the remote side.
-  absl::Notification consumed_parcels;
-  const IpczTrapConditions all_parcels_consumed = {
-      .size = sizeof(all_parcels_consumed),
-      .flags = IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS,
-      .max_remote_parcels = 1,
-  };
-  EXPECT_EQ(
-      IPCZ_RESULT_OK,
-      Trap(c, all_parcels_consumed, [&](const IpczTrapEvent& event) {
-        EXPECT_TRUE(event.condition_flags & IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS);
-        consumed_parcels.Notify();
-      }));
-
-  absl::Notification consumed_bytes;
-  EXPECT_EQ(
-      IPCZ_RESULT_OK,
-      Trap(c, all_bytes_consumed, [&](const IpczTrapEvent& event) {
-        EXPECT_TRUE(event.condition_flags & IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES);
-        consumed_bytes.Notify();
-      }));
-
-  // Ack back to the client so it will read its queue. Then we can wait for both
-  // traps to notify.
-  EXPECT_EQ(IPCZ_RESULT_OK, Put(c, "ok"));
-  consumed_parcels.WaitForNotification();
-  consumed_bytes.WaitForNotification();
-
-  // And now this Put operation should succeed.
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            PutWithLimits(c, {.max_queued_parcels = 1, .max_queued_bytes = 4},
-                          "meh!"));
-
-  Close(c);
-}
-
-MULTINODE_TEST_NODE(QueueingTestNode, TwoPhaseQueueingClient) {
-  IpczHandle b = ConnectToBroker();
-  WaitForDirectRemoteLink(b);
-  EXPECT_EQ(IPCZ_RESULT_OK, Put(b, "go"));
-
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            WaitForConditions(b, {.flags = IPCZ_TRAP_ABOVE_MIN_LOCAL_PARCELS,
-                                  .min_local_parcels = 0}));
-  size_t num_bytes;
-  const void* data;
-  EXPECT_EQ(IPCZ_RESULT_OK, ipcz().BeginGet(b, IPCZ_NO_FLAGS, nullptr, &data,
-                                            &num_bytes, nullptr));
-
-  // The producer should only have been able to put 3 out of its 4 bytes.
-  EXPECT_EQ("ipc",
-            std::string_view(reinterpret_cast<const char*>(data), num_bytes));
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            ipcz().EndGet(b, num_bytes, 0, IPCZ_NO_FLAGS, nullptr, nullptr));
-
-  Close(b);
-}
-
-// Disabled because remote queue state monitoring has been temporarily dropped
-// from ipcz to improve performance. See https://crbug.com/1383754.
-MULTINODE_TEST(QueueingTest, DISABLED_TwoPhaseQueueing) {
-  IpczHandle c = SpawnTestNode<TwoPhaseQueueingClient>();
-  WaitForDirectRemoteLink(c);
-
-  std::string message;
-  EXPECT_EQ(IPCZ_RESULT_OK, WaitToGet(c, &message));
-  EXPECT_EQ("go", message);
-
-  const IpczPutLimits limits = {
-      .size = sizeof(limits),
-      .max_queued_parcels = 1,
-      .max_queued_bytes = 3,
-  };
-
-  size_t num_bytes = 4;
-  void* data;
-  const IpczBeginPutOptions options = {.size = sizeof(options),
-                                       .limits = &limits};
-  EXPECT_EQ(IPCZ_RESULT_OK, ipcz().BeginPut(c, IPCZ_BEGIN_PUT_ALLOW_PARTIAL,
-                                            &options, &num_bytes, &data));
-
-  // There should not be enough space for all 4 bytes.
-  EXPECT_EQ(3u, num_bytes);
-  memcpy(data, "ipc", 3);
-  EXPECT_EQ(IPCZ_RESULT_OK, ipcz().EndPut(c, data, num_bytes, nullptr, 0,
-                                          IPCZ_NO_FLAGS, nullptr));
-
-  EXPECT_EQ(IPCZ_RESULT_OK, WaitForConditionFlags(c, IPCZ_TRAP_PEER_CLOSED));
-  Close(c);
-}
-
-MULTINODE_TEST_NODE(QueueingTestNode, TwoPhaseFeedbackClient) {
-  IpczHandle b = ConnectToBroker();
-  WaitForDirectRemoteLink(b);
-
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            WaitForConditions(b, {.flags = IPCZ_TRAP_ABOVE_MIN_LOCAL_PARCELS,
-                                  .min_local_parcels = 0}));
-  size_t num_bytes;
-  const void* data;
-  EXPECT_EQ(IPCZ_RESULT_OK, ipcz().BeginGet(b, IPCZ_NO_FLAGS, nullptr, &data,
-                                            &num_bytes, nullptr));
-
-  EXPECT_EQ("hello?",
-            std::string_view(reinterpret_cast<const char*>(data), num_bytes));
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            ipcz().EndGet(b, num_bytes, 0, IPCZ_NO_FLAGS, nullptr, nullptr));
-  Close(b);
-}
-
-// TODO(https://crbug.com/1361670): Fix flakiness and re-enable this test.
-MULTINODE_TEST(QueueingTest, DISABLED_TwoPhaseFeedback) {
-  IpczHandle c = SpawnTestNode<TwoPhaseFeedbackClient>();
-  WaitForDirectRemoteLink(c);
-  EXPECT_EQ(IPCZ_RESULT_OK, Put(c, "hello?"));
-  EXPECT_EQ(IPCZ_RESULT_OK,
-            WaitForConditions(c, {.flags = IPCZ_TRAP_BELOW_MAX_REMOTE_PARCELS,
-                                  .max_remote_parcels = 1}));
-  Close(c);
-}
-
-constexpr size_t kStressTestPortalCapacity = 256;
-constexpr size_t kStressTestPayloadSize = 4 * 1024 * 1024;
-
-MULTINODE_TEST_NODE(QueueingTestNode, RemoteQueueFeedbackStressTestClient) {
-  IpczHandle b = ConnectToBroker();
-
-  size_t bytes_received = 0;
-  while (bytes_received < kStressTestPayloadSize) {
-    // Consistency check: ensure that the portal never has more than
-    // kStressTestPortalCapacity bytes available to retrieve. Otherwise limits
-    // were not properly enforced by the sender.
-    IpczPortalStatus status = {.size = sizeof(status)};
-    EXPECT_EQ(IPCZ_RESULT_OK,
-              ipcz().QueryPortalStatus(b, IPCZ_NO_FLAGS, nullptr, &status));
-    EXPECT_LE(status.num_local_bytes, kStressTestPortalCapacity);
-
-    const void* data;
-    size_t num_bytes;
-    const IpczResult begin_result =
-        ipcz().BeginGet(b, IPCZ_NO_FLAGS, nullptr, &data, &num_bytes, nullptr);
-    if (begin_result == IPCZ_RESULT_OK) {
-      bytes_received += num_bytes;
-      EXPECT_EQ(std::string_view(static_cast<const char*>(data), num_bytes),
-                std::string(num_bytes, '!'));
-      EXPECT_EQ(IPCZ_RESULT_OK, ipcz().EndGet(b, num_bytes, 0, IPCZ_NO_FLAGS,
-                                              nullptr, nullptr));
-      continue;
-    }
-
-    ASSERT_EQ(IPCZ_RESULT_UNAVAILABLE, begin_result);
-    WaitForConditions(
-        b, {.flags = IPCZ_TRAP_ABOVE_MIN_LOCAL_BYTES, .min_local_bytes = 0});
-  }
-
-  Close(b);
-}
-
-// Disabled because remote queue state monitoring has been temporarily dropped
-// from ipcz to improve performance. See https://crbug.com/1383754.
-MULTINODE_TEST(QueueingTest, DISABLED_RemoteQueueFeedbackStressTest) {
-  IpczHandle c = SpawnTestNode<RemoteQueueFeedbackStressTestClient>();
-
-  size_t bytes_remaining = kStressTestPayloadSize;
-  while (bytes_remaining) {
-    void* data;
-    size_t capacity = bytes_remaining;
-    const IpczPutLimits limits = {
-        .size = sizeof(limits),
-        .max_queued_parcels = std::numeric_limits<size_t>::max(),
-        .max_queued_bytes = kStressTestPortalCapacity,
-    };
-    const IpczBeginPutOptions options = {
-        .size = sizeof(options),
-        .limits = &limits,
-    };
-    const IpczResult begin_result = ipcz().BeginPut(
-        c, IPCZ_BEGIN_PUT_ALLOW_PARTIAL, &options, &capacity, &data);
-    if (begin_result == IPCZ_RESULT_OK) {
-      size_t num_bytes = std::min(bytes_remaining, capacity);
-      bytes_remaining -= num_bytes;
-      memset(data, '!', num_bytes);
-      EXPECT_EQ(IPCZ_RESULT_OK, ipcz().EndPut(c, data, num_bytes, nullptr, 0,
-                                              IPCZ_NO_FLAGS, nullptr));
-      continue;
-    }
-    ASSERT_EQ(IPCZ_RESULT_RESOURCE_EXHAUSTED, begin_result);
-
-    EXPECT_EQ(
-        IPCZ_RESULT_OK,
-        WaitForConditions(c, {.flags = IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES,
-                              .max_remote_bytes = kStressTestPortalCapacity}));
-  }
-
-  WaitForConditionFlags(c, IPCZ_TRAP_PEER_CLOSED);
-  Close(c);
-}
-
-}  // namespace
-}  // namespace ipcz
diff --git a/src/test/test_base.cc b/src/test/test_base.cc
index f20617e..c70c5e7 100644
--- a/src/test/test_base.cc
+++ b/src/test/test_base.cc
@@ -78,20 +78,6 @@
                     handles.size(), IPCZ_NO_FLAGS, nullptr);
 }
 
-IpczResult TestBase::PutWithLimits(IpczHandle portal,
-                                   const IpczPutLimits& limits,
-                                   std::string_view message,
-                                   absl::Span<IpczHandle> handles) {
-  IpczPutLimits sized_limits = limits;
-  sized_limits.size = sizeof(sized_limits);
-  const IpczPutOptions options = {
-      .size = sizeof(options),
-      .limits = &sized_limits,
-  };
-  return ipcz().Put(portal, message.data(), message.size(), handles.data(),
-                    handles.size(), IPCZ_NO_FLAGS, &options);
-}
-
 IpczResult TestBase::Get(IpczHandle portal,
                          std::string* message,
                          absl::Span<IpczHandle> handles) {
diff --git a/src/test/test_base.h b/src/test/test_base.h
index 8540644..19a7a33 100644
--- a/src/test/test_base.h
+++ b/src/test/test_base.h
@@ -42,10 +42,6 @@
   IpczResult Put(IpczHandle portal,
                  std::string_view message,
                  absl::Span<IpczHandle> handles = {});
-  IpczResult PutWithLimits(IpczHandle portal,
-                           const IpczPutLimits& limits,
-                           std::string_view message,
-                           absl::Span<IpczHandle> handles = {});
 
   // Shorthand for ipcz Get() to retrieve the next available parcel from
   // `portal`.If no parcel is available, or any other condition prevents Get()