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 <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2025-08-25 16:12:27 +02:00 committed by GitHub
parent e21ea2a135
commit cf13fd4628
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 14 deletions

View file

@ -99,7 +99,7 @@ use background_hang_monitor::HangMonitorRegister;
use background_hang_monitor_api::{ use background_hang_monitor_api::{
BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, HangMonitorAlert, BackgroundHangMonitorControlMsg, BackgroundHangMonitorRegister, HangMonitorAlert,
}; };
use base::generic_channel::GenericSender; use base::generic_channel::{GenericSender, RoutedReceiver};
use base::id::{ use base::id::{
BrowsingContextGroupId, BrowsingContextId, HistoryStateId, MessagePortId, MessagePortRouterId, BrowsingContextGroupId, BrowsingContextId, HistoryStateId, MessagePortId, MessagePortRouterId,
PipelineId, PipelineNamespace, PipelineNamespaceId, PipelineNamespaceRequest, WebViewId, PipelineId, PipelineNamespace, PipelineNamespaceId, PipelineNamespaceRequest, WebViewId,
@ -284,8 +284,8 @@ pub struct Constellation<STF, SWF> {
/// An ipc-sender/threaded-receiver pair /// An ipc-sender/threaded-receiver pair
/// to facilitate installing pipeline namespaces in threads /// to facilitate installing pipeline namespaces in threads
/// via a per-process installer. /// via a per-process installer.
namespace_receiver: Receiver<Result<PipelineNamespaceRequest, IpcError>>, namespace_receiver: RoutedReceiver<PipelineNamespaceRequest>,
namespace_ipc_sender: IpcSender<PipelineNamespaceRequest>, namespace_ipc_sender: GenericSender<PipelineNamespaceRequest>,
/// An IPC channel for script threads to send messages to the constellation. /// An IPC channel for script threads to send messages to the constellation.
/// This is the script threads' view of `script_receiver`. /// This is the script threads' view of `script_receiver`.
@ -293,7 +293,7 @@ pub struct Constellation<STF, SWF> {
/// A channel for the constellation to receive messages from script threads. /// A channel for the constellation to receive messages from script threads.
/// This is the constellation's view of `script_sender`. /// 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. /// A handle to register components for hang monitoring.
/// None when in multiprocess mode. /// None when in multiprocess mode.
@ -610,11 +610,8 @@ where
let script_receiver = script_ipc_receiver.route_preserving_errors(); let script_receiver = script_ipc_receiver.route_preserving_errors();
let (namespace_ipc_sender, namespace_ipc_receiver) = let (namespace_ipc_sender, namespace_ipc_receiver) =
ipc::channel().expect("ipc channel failure"); generic_channel::channel().expect("ipc channel failure");
let namespace_receiver = let namespace_receiver = namespace_ipc_receiver.route_preserving_errors();
route_ipc_receiver_to_new_crossbeam_receiver_preserving_errors(
namespace_ipc_receiver,
);
let (background_hang_monitor_ipc_sender, background_hang_monitor_ipc_receiver) = let (background_hang_monitor_ipc_sender, background_hang_monitor_ipc_receiver) =
ipc::channel().expect("ipc channel failure"); ipc::channel().expect("ipc channel failure");

View file

@ -132,7 +132,7 @@ pub struct InitialPipelineState {
pub script_to_constellation_chan: ScriptToConstellationChan, pub script_to_constellation_chan: ScriptToConstellationChan,
/// A sender to request pipeline namespace ids. /// A sender to request pipeline namespace ids.
pub namespace_request_sender: IpcSender<PipelineNamespaceRequest>, pub namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
/// A handle to register components for hang monitoring. /// A handle to register components for hang monitoring.
/// None when in multiprocess mode. /// None when in multiprocess mode.
@ -470,7 +470,7 @@ pub struct UnprivilegedPipelineContent {
browsing_context_id: BrowsingContextId, browsing_context_id: BrowsingContextId,
parent_pipeline_id: Option<PipelineId>, parent_pipeline_id: Option<PipelineId>,
opener: Option<BrowsingContextId>, opener: Option<BrowsingContextId>,
namespace_request_sender: IpcSender<PipelineNamespaceRequest>, namespace_request_sender: GenericSender<PipelineNamespaceRequest>,
script_to_constellation_chan: ScriptToConstellationChan, script_to_constellation_chan: ScriptToConstellationChan,
background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>, background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
bhm_control_port: Option<IpcReceiver<BackgroundHangMonitorControlMsg>>, bhm_control_port: Option<IpcReceiver<BackgroundHangMonitorControlMsg>>,

View file

@ -19,6 +19,8 @@ use parking_lot::Mutex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use webrender_api::{ExternalScrollId, PipelineId as WebRenderPipelineId}; use webrender_api::{ExternalScrollId, PipelineId as WebRenderPipelineId};
use crate::generic_channel::GenericSender;
/// Asserts the size of a type at compile time. /// Asserts the size of a type at compile time.
macro_rules! size_of_test { macro_rules! size_of_test {
($t: ty, $expected_size: expr) => { ($t: ty, $expected_size: expr) => {
@ -119,7 +121,7 @@ pub struct PipelineNamespaceRequest(pub IpcSender<PipelineNamespaceId>);
/// A per-process installer of pipeline-namespaces. /// A per-process installer of pipeline-namespaces.
pub struct PipelineNamespaceInstaller { pub struct PipelineNamespaceInstaller {
request_sender: Option<IpcSender<PipelineNamespaceRequest>>, request_sender: Option<GenericSender<PipelineNamespaceRequest>>,
namespace_sender: IpcSender<PipelineNamespaceId>, namespace_sender: IpcSender<PipelineNamespaceId>,
namespace_receiver: IpcReceiver<PipelineNamespaceId>, namespace_receiver: IpcReceiver<PipelineNamespaceId>,
} }
@ -138,7 +140,7 @@ impl Default for PipelineNamespaceInstaller {
impl PipelineNamespaceInstaller { impl PipelineNamespaceInstaller {
/// Provide a request sender to send requests to the constellation. /// Provide a request sender to send requests to the constellation.
pub fn set_sender(&mut self, sender: IpcSender<PipelineNamespaceRequest>) { pub fn set_sender(&mut self, sender: GenericSender<PipelineNamespaceRequest>) {
self.request_sender = Some(sender); 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. /// Setup the pipeline-namespace-installer, by providing it with a sender to the constellation.
/// Idempotent in single-process mode. /// Idempotent in single-process mode.
pub fn set_installer_sender(sender: IpcSender<PipelineNamespaceRequest>) { pub fn set_installer_sender(sender: GenericSender<PipelineNamespaceRequest>) {
PIPELINE_NAMESPACE_INSTALLER.lock().set_sender(sender); PIPELINE_NAMESPACE_INSTALLER.lock().set_sender(sender);
} }