mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
GenericChannel: Migrate compositor channels to GenericChannel (#38782)
Besides migrating the channel to GenericChannel, this PR adds `routed_channel_with_local_sender()` to `generic_channel`. This is for existing use-cases, where we want to provide both an IPC capable GenericSender, as well as a crossbeam Sender, for efficient sending if the sender is in the same process. Testing: All of our channels should send / receive at least some messages during WPT tests. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
7441944e36
commit
fb1c0a4c48
9 changed files with 98 additions and 43 deletions
|
@ -8,6 +8,7 @@ use std::collections::HashMap;
|
|||
use std::fmt;
|
||||
|
||||
use base::Epoch;
|
||||
use base::generic_channel::{GenericSender, SendResult};
|
||||
use base::id::{
|
||||
BroadcastChannelRouterId, BrowsingContextId, HistoryStateId, MessagePortId,
|
||||
MessagePortRouterId, PipelineId, ServiceWorkerId, ServiceWorkerRegistrationId, WebViewId,
|
||||
|
@ -21,7 +22,6 @@ use embedder_traits::{
|
|||
};
|
||||
use euclid::default::Size2D as UntypedSize2D;
|
||||
use http::{HeaderMap, Method};
|
||||
use ipc_channel::Error as IpcError;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use net_traits::policy_container::PolicyContainer;
|
||||
|
@ -46,14 +46,14 @@ use crate::{
|
|||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||
pub struct ScriptToConstellationChan {
|
||||
/// Sender for communicating with constellation thread.
|
||||
pub sender: IpcSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||
pub sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||
/// Used to identify the origin of the message.
|
||||
pub pipeline_id: PipelineId,
|
||||
}
|
||||
|
||||
impl ScriptToConstellationChan {
|
||||
/// Send ScriptMsg and attach the pipeline_id to the message.
|
||||
pub fn send(&self, msg: ScriptToConstellationMessage) -> Result<(), IpcError> {
|
||||
pub fn send(&self, msg: ScriptToConstellationMessage) -> SendResult {
|
||||
self.sender.send((self.pipeline_id, msg))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue