mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
introduce ScriptToConstellationChan
This commit is contained in:
parent
bb3ac8f266
commit
817de15735
1 changed files with 19 additions and 2 deletions
|
@ -45,6 +45,7 @@ use gfx_traits::Epoch;
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
use hyper::header::Headers;
|
use hyper::header::Headers;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
|
use ipc_channel::{Error as IpcError};
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use msg::constellation_msg::{BrowsingContextId, TopLevelBrowsingContextId, FrameType, Key, KeyModifiers, KeyState};
|
use msg::constellation_msg::{BrowsingContextId, TopLevelBrowsingContextId, FrameType, Key, KeyModifiers, KeyState};
|
||||||
|
@ -500,7 +501,7 @@ pub struct InitialScriptState {
|
||||||
/// A port on which messages sent by the constellation to script can be received.
|
/// A port on which messages sent by the constellation to script can be received.
|
||||||
pub control_port: IpcReceiver<ConstellationControlMsg>,
|
pub control_port: IpcReceiver<ConstellationControlMsg>,
|
||||||
/// A channel on which messages can be sent to the constellation from script.
|
/// A channel on which messages can be sent to the constellation from script.
|
||||||
pub constellation_chan: IpcSender<ScriptMsg>,
|
pub script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
/// A sender for the layout thread to communicate to the constellation.
|
/// A sender for the layout thread to communicate to the constellation.
|
||||||
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
/// A channel to schedule timer events.
|
/// A channel to schedule timer events.
|
||||||
|
@ -780,7 +781,7 @@ pub struct WorkerGlobalScopeInit {
|
||||||
/// From devtools sender
|
/// From devtools sender
|
||||||
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||||
/// Messages to send to constellation
|
/// Messages to send to constellation
|
||||||
pub constellation_chan: IpcSender<ScriptMsg>,
|
pub script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
/// Message to send to the scheduler
|
/// Message to send to the scheduler
|
||||||
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||||
/// The worker id
|
/// The worker id
|
||||||
|
@ -843,3 +844,19 @@ pub struct DrawAPaintImageResult {
|
||||||
/// Drawing the image might have requested loading some image URLs.
|
/// Drawing the image might have requested loading some image URLs.
|
||||||
pub missing_image_urls: Vec<ServoUrl>,
|
pub missing_image_urls: Vec<ServoUrl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A Script to Constellation channel.
|
||||||
|
#[derive(Deserialize, Serialize, Clone)]
|
||||||
|
pub struct ScriptToConstellationChan {
|
||||||
|
/// Sender for communicating with constellation thread.
|
||||||
|
pub sender: IpcSender<(PipelineId, ScriptMsg)>,
|
||||||
|
/// 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: ScriptMsg) -> Result<(), IpcError> {
|
||||||
|
self.sender.send((self.pipeline_id, msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue