diff options
-rw-r--r-- | components/compositing/constellation.rs | 6 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 17 | ||||
-rw-r--r-- | components/gfx/paint_task.rs | 19 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 22 | ||||
-rw-r--r-- | components/msg/constellation_msg.rs | 8 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 4 | ||||
-rw-r--r-- | components/script/script_task.rs | 18 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 6 |
8 files changed, 46 insertions, 54 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index adfb9fb5b21..c4b1c9bd5d4 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -25,7 +25,7 @@ use msg::compositor_msg::Epoch; use msg::constellation_msg::AnimationState; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::WebDriverCommandMsg; -use msg::constellation_msg::{FrameId, PipelineExitType, PipelineId}; +use msg::constellation_msg::{FrameId, PipelineId}; use msg::constellation_msg::{IframeLoadInfo, IFrameSandboxState, MozBrowserEvent, NavigationDirection}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId}; @@ -565,7 +565,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn handle_exit(&mut self) { for (_id, ref pipeline) in &self.pipelines { - pipeline.exit(PipelineExitType::Complete); + pipeline.exit(); } self.image_cache_task.exit(); self.resource_task.send(net_traits::ControlMsg::Exit).unwrap(); @@ -1356,7 +1356,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // Inform script, compositor that this pipeline has exited. match exit_mode { - ExitPipelineMode::Normal => pipeline.exit(PipelineExitType::PipelineOnly), + ExitPipelineMode::Normal => pipeline.exit(), ExitPipelineMode::Force => pipeline.force_exit(), } } diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index ad425224d26..4cc8b87f14a 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -15,7 +15,7 @@ use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; -use msg::constellation_msg::{LoadData, MozBrowserEvent, PipelineExitType, WindowSizeData}; +use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; use msg::constellation_msg::{PipelineNamespaceId}; use net_traits::ResourceTask; use net_traits::image_cache_task::ImageCacheTask; @@ -248,13 +248,13 @@ impl Pipeline { let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::PaintPermissionRevoked); } - pub fn exit(&self, exit_type: PipelineExitType) { + pub fn exit(&self) { debug!("pipeline {:?} exiting", self.id); // Script task handles shutting down layout, and layout handles shutting down the painter. // For now, if the script task has failed, we give up on clean shutdown. if self.script_chan - .send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)) + .send(ConstellationControlMsg::ExitPipeline(self.id)) .is_ok() { // Wait until all slave tasks have terminated and run destructors // NOTE: We don't wait for script task as we don't always own it @@ -275,15 +275,10 @@ impl Pipeline { } pub fn force_exit(&self) { - let _ = self.script_chan.send( - ConstellationControlMsg::ExitPipeline(self.id, - PipelineExitType::PipelineOnly)).unwrap(); - let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit( - None, - PipelineExitType::PipelineOnly)); + let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap(); + let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit); let LayoutControlChan(ref layout_channel) = self.layout_chan; - let _ = layout_channel.send( - LayoutControlMsg::ExitNow(PipelineExitType::PipelineOnly)).unwrap(); + let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap(); } pub fn to_sendable(&self) -> CompositionPipeline { diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index cd996c5b8f2..926aa2fe123 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -22,7 +22,7 @@ use layers::platform::surface::{NativeDisplay, NativeSurface}; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties}; use msg::compositor_msg::{PaintListener, ScrollPolicy}; use msg::constellation_msg::Msg as ConstellationMsg; -use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId}; +use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use paint_context::PaintContext; use profile_traits::mem::{self, ReportsChan}; use profile_traits::time::{self, profile}; @@ -197,7 +197,7 @@ pub enum Msg { pub enum LayoutToPaintMsg { PaintInit(Epoch, PaintLayer), CanvasLayer(LayerId, IpcSender<CanvasMsg>), - Exit(Option<IpcSender<()>>, PipelineExitType), + Exit(IpcSender<()>), } pub enum ChromeToPaintMsg { @@ -205,7 +205,7 @@ pub enum ChromeToPaintMsg { PaintPermissionGranted, PaintPermissionRevoked, CollectReports(ReportsChan), - Exit(Option<IpcSender<()>>, PipelineExitType), + Exit, } pub struct PaintTask<C> { @@ -382,14 +382,21 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { // FIXME(njn): should eventually measure the paint task. channel.send(Vec::new()) } - Msg::FromLayout(LayoutToPaintMsg::Exit(ref response_channel, _)) | - Msg::FromChrome(ChromeToPaintMsg::Exit(ref response_channel, _)) => { + Msg::FromLayout(LayoutToPaintMsg::Exit(ref response_channel)) => { + // Ask the compositor to remove any layers it is holding for this paint task. + // FIXME(mrobinson): This can probably move back to the constellation now. + self.compositor.notify_paint_task_exiting(self.id); + + debug!("PaintTask: Exiting."); + let _ = response_channel.send(()); + break; + } + Msg::FromChrome(ChromeToPaintMsg::Exit) => { // Ask the compositor to remove any layers it is holding for this paint task. // FIXME(mrobinson): This can probably move back to the constellation now. self.compositor.notify_paint_task_exiting(self.id); debug!("PaintTask: Exiting."); - response_channel.as_ref().map(|channel| channel.send(())); break; } } diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 8881a174dec..c001fc31ee9 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -40,7 +40,7 @@ use layout_traits::LayoutTaskFactory; use log; use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy}; use msg::constellation_msg::Msg as ConstellationMsg; -use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId}; +use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; use net_traits::{PendingAsyncLoad, load_bytes_iter}; use opaque_node::OpaqueNodeMethods; @@ -493,8 +493,8 @@ impl LayoutTask { self.handle_request_helper(Msg::GetWebFontLoadState(sender), possibly_locked_rw_data) } - LayoutControlMsg::ExitNow(exit_type) => { - self.handle_request_helper(Msg::ExitNow(exit_type), + LayoutControlMsg::ExitNow => { + self.handle_request_helper(Msg::ExitNow, possibly_locked_rw_data) } } @@ -632,9 +632,9 @@ impl LayoutTask { self.prepare_to_exit(response_chan, possibly_locked_rw_data); return false }, - Msg::ExitNow(exit_type) => { + Msg::ExitNow => { debug!("layout: ExitNow received"); - self.exit_now(possibly_locked_rw_data, exit_type); + self.exit_now(possibly_locked_rw_data); return false } } @@ -712,9 +712,9 @@ impl LayoutTask { self.handle_reap_layout_data(dead_layout_data) } } - Msg::ExitNow(exit_type) => { + Msg::ExitNow => { debug!("layout task is exiting..."); - self.exit_now(possibly_locked_rw_data, exit_type); + self.exit_now(possibly_locked_rw_data); break } Msg::CollectReports(_) => { @@ -730,10 +730,7 @@ impl LayoutTask { /// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely) /// crash. fn exit_now<'a>(&'a self, - possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>, - exit_type: PipelineExitType) { - let (response_chan, response_port) = ipc::channel().unwrap(); - + possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) { { let mut rw_data = self.lock_rw_data(possibly_locked_rw_data); if let Some(ref mut traversal) = (&mut *rw_data).parallel_traversal { @@ -742,7 +739,8 @@ impl LayoutTask { LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data); } - self.paint_chan.send(LayoutToPaintMsg::Exit(Some(response_chan), exit_type)).unwrap(); + let (response_chan, response_port) = ipc::channel().unwrap(); + self.paint_chan.send(LayoutToPaintMsg::Exit(response_chan)).unwrap(); response_port.recv().unwrap() } diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 98fdcc052fb..26fcb842d0e 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -517,11 +517,3 @@ impl fmt::Display for PipelineId { #[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)] pub struct SubpageId(pub u32); - -// The type of pipeline exit. During complete shutdowns, pipelines do not have to -// release resources automatically released on process termination. -#[derive(Copy, Clone, Debug, Deserialize, Serialize)] -pub enum PipelineExitType { - PipelineOnly, - Complete, -} diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index afc7adedbd3..7a735d22737 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -14,7 +14,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::uintptr_t; use msg::compositor_msg::Epoch; use msg::compositor_msg::LayerId; -use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId}; +use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{WindowSizeData}; use net_traits::PendingAsyncLoad; use net_traits::image_cache_task::ImageCacheTask; @@ -78,7 +78,7 @@ pub enum Msg { /// Requests that the layout task immediately shut down. There must be no more nodes left after /// this, or layout will crash. - ExitNow(PipelineExitType), + ExitNow, /// Get the last epoch counter for this layout task. GetCurrentEpoch(IpcSender<Epoch>), diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 773d43448c4..fcf29605b80 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -64,7 +64,7 @@ use mem::heap_size_of_self_and_children; use msg::compositor_msg::{EventResult, LayerId, ScriptToCompositorMsg}; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, FocusType, LoadData}; -use msg::constellation_msg::{MozBrowserEvent, PipelineExitType, PipelineId}; +use msg::constellation_msg::{MozBrowserEvent, PipelineId}; use msg::constellation_msg::{PipelineNamespace}; use msg::constellation_msg::{SubpageId, WindowSizeData, WorkerId}; use msg::webdriver_msg::WebDriverScriptCommand; @@ -871,8 +871,8 @@ impl ScriptTask { let result = self.profile_event(category, move || { match msg { - MixedMessage::FromConstellation(ConstellationControlMsg::ExitPipeline(id, exit_type)) => { - if self.handle_exit_pipeline_msg(id, exit_type) { + MixedMessage::FromConstellation(ConstellationControlMsg::ExitPipeline(id)) => { + if self.handle_exit_pipeline_msg(id) { return Some(false) } }, @@ -1472,7 +1472,7 @@ impl ScriptTask { /// Handles a request to exit the script task and shut down layout. /// Returns true if the script task should shut down and false otherwise. - fn handle_exit_pipeline_msg(&self, id: PipelineId, exit_type: PipelineExitType) -> bool { + fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool { self.closed_pipelines.borrow_mut().insert(id); // Check if the exit message is for an in progress load. @@ -1490,7 +1490,7 @@ impl ScriptTask { if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() { debug!("shutting down layout for page {:?}", id); response_port.recv().unwrap(); - chan.send(layout_interface::Msg::ExitNow(exit_type)).ok(); + chan.send(layout_interface::Msg::ExitNow).ok(); } let has_pending_loads = self.incomplete_loads.borrow().len() > 0; @@ -1505,13 +1505,13 @@ impl ScriptTask { let window = page.window(); if window.pipeline() == id { debug!("shutting down layout for root page {:?}", id); - shut_down_layout(&page, exit_type); + shut_down_layout(&page); return true } // otherwise find just the matching page and exit all sub-pages if let Some(ref mut child_page) = page.remove(id) { - shut_down_layout(&*child_page, exit_type); + shut_down_layout(&*child_page); } false } @@ -2027,7 +2027,7 @@ impl Drop for ScriptTask { } /// Shuts down layout for the given page tree. -fn shut_down_layout(page_tree: &Rc<Page>, exit_type: PipelineExitType) { +fn shut_down_layout(page_tree: &Rc<Page>) { let mut channels = vec!(); for page in page_tree.iter() { @@ -2052,7 +2052,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, exit_type: PipelineExitType) { // Destroy the layout task. If there were node leaks, layout will now crash safely. for chan in channels { - chan.send(layout_interface::Msg::ExitNow(exit_type)).ok(); + chan.send(layout_interface::Msg::ExitNow).ok(); } } diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 827a729e236..ba65e0e2c7a 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -33,7 +33,7 @@ use libc::c_void; use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId}; -use msg::constellation_msg::{MozBrowserEvent, PipelineExitType, PipelineNamespaceId}; +use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::ResourceTask; use net_traits::image_cache_task::ImageCacheTask; @@ -55,7 +55,7 @@ unsafe impl Send for UntrustedNodeAddress {} #[derive(Deserialize, Serialize)] pub enum LayoutControlMsg { /// Requests that this layout task exit. - ExitNow(PipelineExitType), + ExitNow, /// Requests the current epoch (layout counter) from this layout. GetCurrentEpoch(IpcSender<Epoch>), /// Asks layout to run another step in its animation. @@ -115,7 +115,7 @@ pub enum ConstellationControlMsg { /// Notifies script that window has been resized but to not take immediate action. ResizeInactive(PipelineId, WindowSizeData), /// Notifies the script that a pipeline should be closed. - ExitPipeline(PipelineId, PipelineExitType), + ExitPipeline(PipelineId), /// Sends a DOM event. SendEvent(PipelineId, CompositorEvent), /// Notifies script of the viewport. |