From cf13fd46288989cfc1d1f7d2ba1b7aa16bec269a Mon Sep 17 00:00:00 2001 From: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Date: Mon, 25 Aug 2025 16:12:27 +0200 Subject: [PATCH] constellation: Migrate namespace channel to GenericChannel (#38913) Migrates the namespace sender and receiver to use GenericChannel Testing: Covered by existing tests Part of #38912 Signed-off-by: Jonathan Schwender --- components/constellation/constellation.rs | 15 ++++++--------- components/constellation/pipeline.rs | 4 ++-- components/shared/base/id.rs | 8 +++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index accfa69e1ec..8ec22e25a55 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -99,7 +99,7 @@ use background_hang_monitor::HangMonitorRegister; use background_hang_monitor_api::{ BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, HangMonitorAlert, }; -use base::generic_channel::GenericSender; +use base::generic_channel::{GenericSender, RoutedReceiver}; use base::id::{ BrowsingContextGroupId, BrowsingContextId, HistoryStateId, MessagePortId, MessagePortRouterId, PipelineId, PipelineNamespace, PipelineNamespaceId, PipelineNamespaceRequest, WebViewId, @@ -284,8 +284,8 @@ pub struct Constellation { /// An ipc-sender/threaded-receiver pair /// to facilitate installing pipeline namespaces in threads /// via a per-process installer. - namespace_receiver: Receiver>, - namespace_ipc_sender: IpcSender, + namespace_receiver: RoutedReceiver, + namespace_ipc_sender: GenericSender, /// An IPC channel for script threads to send messages to the constellation. /// This is the script threads' view of `script_receiver`. @@ -293,7 +293,7 @@ pub struct Constellation { /// A channel for the constellation to receive messages from script threads. /// This is the constellation's view of `script_sender`. - script_receiver: generic_channel::RoutedReceiver<(PipelineId, ScriptToConstellationMessage)>, + script_receiver: RoutedReceiver<(PipelineId, ScriptToConstellationMessage)>, /// A handle to register components for hang monitoring. /// None when in multiprocess mode. @@ -610,11 +610,8 @@ where let script_receiver = script_ipc_receiver.route_preserving_errors(); let (namespace_ipc_sender, namespace_ipc_receiver) = - ipc::channel().expect("ipc channel failure"); - let namespace_receiver = - route_ipc_receiver_to_new_crossbeam_receiver_preserving_errors( - namespace_ipc_receiver, - ); + generic_channel::channel().expect("ipc channel failure"); + let namespace_receiver = namespace_ipc_receiver.route_preserving_errors(); let (background_hang_monitor_ipc_sender, background_hang_monitor_ipc_receiver) = ipc::channel().expect("ipc channel failure"); diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 2a34c415e5d..83db415e84c 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -132,7 +132,7 @@ pub struct InitialPipelineState { pub script_to_constellation_chan: ScriptToConstellationChan, /// A sender to request pipeline namespace ids. - pub namespace_request_sender: IpcSender, + pub namespace_request_sender: GenericSender, /// A handle to register components for hang monitoring. /// None when in multiprocess mode. @@ -470,7 +470,7 @@ pub struct UnprivilegedPipelineContent { browsing_context_id: BrowsingContextId, parent_pipeline_id: Option, opener: Option, - namespace_request_sender: IpcSender, + namespace_request_sender: GenericSender, script_to_constellation_chan: ScriptToConstellationChan, background_hang_monitor_to_constellation_chan: IpcSender, bhm_control_port: Option>, diff --git a/components/shared/base/id.rs b/components/shared/base/id.rs index a24e355a2d0..b9730bcf3f7 100644 --- a/components/shared/base/id.rs +++ b/components/shared/base/id.rs @@ -19,6 +19,8 @@ use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use webrender_api::{ExternalScrollId, PipelineId as WebRenderPipelineId}; +use crate::generic_channel::GenericSender; + /// Asserts the size of a type at compile time. macro_rules! size_of_test { ($t: ty, $expected_size: expr) => { @@ -119,7 +121,7 @@ pub struct PipelineNamespaceRequest(pub IpcSender); /// A per-process installer of pipeline-namespaces. pub struct PipelineNamespaceInstaller { - request_sender: Option>, + request_sender: Option>, namespace_sender: IpcSender, namespace_receiver: IpcReceiver, } @@ -138,7 +140,7 @@ impl Default for PipelineNamespaceInstaller { impl PipelineNamespaceInstaller { /// Provide a request sender to send requests to the constellation. - pub fn set_sender(&mut self, sender: IpcSender) { + pub fn set_sender(&mut self, sender: GenericSender) { self.request_sender = Some(sender); } @@ -207,7 +209,7 @@ impl PipelineNamespace { /// Setup the pipeline-namespace-installer, by providing it with a sender to the constellation. /// Idempotent in single-process mode. - pub fn set_installer_sender(sender: IpcSender) { + pub fn set_installer_sender(sender: GenericSender) { PIPELINE_NAMESPACE_INSTALLER.lock().set_sender(sender); }