diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index c5c262d0abc..83e5c0c2bc1 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -29,7 +29,9 @@ use std::mem; use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use url::Url; +use util; use util::geometry::{PagePx, ViewportPx}; +use util::ipc::OptionalIpcSender; use util::opts; /// A uniquely-identifiable pipeline of script task, layout task, and paint task. @@ -83,7 +85,7 @@ impl Pipeline { device_pixel_ratio: ScaleFactor) -> (Pipeline, PipelineContent) where LTF: LayoutTaskFactory, STF:ScriptTaskFactory { - let (layout_to_paint_chan, layout_to_paint_port) = channel(); + let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel(); let (chrome_to_paint_chan, chrome_to_paint_port) = channel(); let (paint_shutdown_chan, paint_shutdown_port) = channel(); let (layout_shutdown_chan, layout_shutdown_port) = channel(); @@ -206,12 +208,12 @@ impl Pipeline { } pub fn grant_paint_permission(&self) { - drop(self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionGranted)); + let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionGranted); } pub fn revoke_paint_permission(&self) { debug!("pipeline revoking paint channel paint permission"); - drop(self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionRevoked)); + let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionRevoked); } pub fn exit(&self, exit_type: PipelineExitType) { @@ -300,7 +302,7 @@ pub struct PipelineContent { load_data: LoadData, failure: Failure, script_port: Option>, - layout_to_paint_chan: Sender, + layout_to_paint_chan: OptionalIpcSender, chrome_to_paint_chan: Sender, layout_to_paint_port: Option>, chrome_to_paint_port: Option>, diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 61ebd29deb9..001f8f42d2a 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -78,6 +78,7 @@ use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; use url::Url; use util::cursor::Cursor; use util::geometry::{Au, MAX_RECT, ZERO_POINT}; +use util::ipc::OptionalIpcSender; use util::logical_geometry::{LogicalPoint, WritingMode}; use util::mem::HeapSizeOf; use util::opts; @@ -187,7 +188,7 @@ pub struct LayoutTask { pub script_chan: ScriptControlChan, /// The channel on which messages can be sent to the painting task. - pub paint_chan: Sender, + pub paint_chan: OptionalIpcSender, /// The channel on which messages can be sent to the time profiler. pub time_profiler_chan: time::ProfilerChan, @@ -227,7 +228,7 @@ impl LayoutTaskFactory for LayoutTask { constellation_chan: ConstellationChan, failure_msg: Failure, script_chan: ScriptControlChan, - paint_chan: Sender, + paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, time_profiler_chan: time::ProfilerChan, @@ -317,7 +318,7 @@ impl LayoutTask { pipeline_port: IpcReceiver, constellation_chan: ConstellationChan, script_chan: ScriptControlChan, - paint_chan: Sender, + paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, time_profiler_chan: time::ProfilerChan, @@ -647,7 +648,7 @@ impl LayoutTask { info.failure, ScriptControlChan(info.script_chan.clone()), *info.paint_chan - .downcast::>() + .downcast::>() .unwrap(), self.image_cache_task.clone(), self.font_cache_task.clone(), diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index 436bccde8a4..d75817911a7 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -31,6 +31,7 @@ use net_traits::image_cache_task::ImageCacheTask; use script_traits::{LayoutControlMsg, ScriptControlChan, OpaqueScriptLayoutChannel}; use std::sync::mpsc::Sender; use url::Url; +use util::ipc::OptionalIpcSender; /// A channel wrapper for constellation messages #[derive(Clone, Deserialize, Serialize)] @@ -49,7 +50,7 @@ pub trait LayoutTaskFactory { constellation_chan: ConstellationChan, failure_msg: Failure, script_chan: ScriptControlChan, - layout_to_paint_chan: Sender, + layout_to_paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, time_profiler_chan: time::ProfilerChan, diff --git a/components/util/ipc.rs b/components/util/ipc.rs index 090ca9c0094..7e47ff696f7 100644 --- a/components/util/ipc.rs +++ b/components/util/ipc.rs @@ -34,6 +34,19 @@ impl OptionalIpcSender where T: Deserialize + Serialize + Send + Any { } } +impl Clone for OptionalIpcSender where T: Deserialize + Serialize + Send + Any { + fn clone(&self) -> OptionalIpcSender { + match *self { + OptionalIpcSender::OutOfProcess(ref ipc_sender) => { + OptionalIpcSender::OutOfProcess((*ipc_sender).clone()) + } + OptionalIpcSender::InProcess(ref sender) => { + OptionalIpcSender::InProcess((*sender).clone()) + } + } + } +} + impl Deserialize for OptionalIpcSender where T: Deserialize + Serialize + Send + Any { fn deserialize(deserializer: &mut D) -> Result,D::Error> where D: Deserializer {