aboutsummaryrefslogtreecommitdiffstats
path: root/components/constellation/pipeline.rs
diff options
context:
space:
mode:
authorGregory Terzian <gterzian@users.noreply.github.com>2018-09-11 15:49:47 +0800
committerGregory Terzian <gterzian@users.noreply.github.com>2018-11-26 14:15:33 +0800
commit4eb785cdc0446539bf5e7eb66bf7ad46ba5705dd (patch)
tree3703ffe374141ff2816b1b3adf6c54ec1bdcf722 /components/constellation/pipeline.rs
parent7c65505df3fff47f43062da20088113631ed9ae0 (diff)
downloadservo-4eb785cdc0446539bf5e7eb66bf7ad46ba5705dd.tar.gz
servo-4eb785cdc0446539bf5e7eb66bf7ad46ba5705dd.zip
introduce a background-hang-monitor:
Mac-Os implementation of a thread sampler, Linux and Windows skeleton implementations.
Diffstat (limited to 'components/constellation/pipeline.rs')
-rw-r--r--components/constellation/pipeline.rs31
1 files changed, 28 insertions, 3 deletions
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index b0df616cbdf..63376315101 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -18,6 +18,7 @@ use ipc_channel::Error;
use layout_traits::LayoutThreadFactory;
use metrics::PaintTimeMetrics;
use msg::constellation_msg::TopLevelBrowsingContextId;
+use msg::constellation_msg::{BackgroundHangMonitorRegister, HangAlert};
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespaceId};
use net::image_cache::ImageCacheImpl;
use net_traits::image_cache::ImageCache;
@@ -113,6 +114,13 @@ pub struct InitialPipelineState {
/// A channel to the associated constellation.
pub script_to_constellation_chan: ScriptToConstellationChan,
+ /// A handle to register components for hang monitoring.
+ /// None when in multiprocess mode.
+ pub background_monitor_register: Option<Box<BackgroundHangMonitorRegister>>,
+
+ /// A channel for the background hang monitor to send messages to the constellation.
+ pub background_hang_monitor_to_constellation_chan: IpcSender<HangAlert>,
+
/// A channel for the layout thread to send messages to the constellation.
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
@@ -262,6 +270,9 @@ impl Pipeline {
parent_pipeline_id: state.parent_pipeline_id,
opener: state.opener,
script_to_constellation_chan: state.script_to_constellation_chan.clone(),
+ background_hang_monitor_to_constellation_chan: state
+ .background_hang_monitor_to_constellation_chan
+ .clone(),
scheduler_chan: state.scheduler_chan,
devtools_chan: script_to_devtools_chan,
bluetooth_thread: state.bluetooth_thread,
@@ -295,7 +306,11 @@ impl Pipeline {
if opts::multiprocess() {
let _ = unprivileged_pipeline_content.spawn_multiprocess()?;
} else {
- unprivileged_pipeline_content.start_all::<Message, LTF, STF>(false);
+ // Should not be None in single-process mode.
+ let register = state
+ .background_monitor_register
+ .expect("Couldn't start content, no background monitor has been initiated");
+ unprivileged_pipeline_content.start_all::<Message, LTF, STF>(false, register);
}
EventLoop::new(script_chan)
@@ -452,6 +467,7 @@ pub struct UnprivilegedPipelineContent {
parent_pipeline_id: Option<PipelineId>,
opener: Option<BrowsingContextId>,
script_to_constellation_chan: ScriptToConstellationChan,
+ background_hang_monitor_to_constellation_chan: IpcSender<HangAlert>,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
@@ -480,8 +496,11 @@ pub struct UnprivilegedPipelineContent {
}
impl UnprivilegedPipelineContent {
- pub fn start_all<Message, LTF, STF>(self, wait_for_completion: bool)
- where
+ pub fn start_all<Message, LTF, STF>(
+ self,
+ wait_for_completion: bool,
+ background_hang_monitor_register: Box<BackgroundHangMonitorRegister>,
+ ) where
LTF: LayoutThreadFactory<Message = Message>,
STF: ScriptThreadFactory<Message = Message>,
{
@@ -503,6 +522,7 @@ impl UnprivilegedPipelineContent {
control_chan: self.script_chan.clone(),
control_port: self.script_port,
script_to_constellation_chan: self.script_to_constellation_chan.clone(),
+ background_hang_monitor_register: background_hang_monitor_register.clone(),
layout_to_constellation_chan: self.layout_to_constellation_chan.clone(),
scheduler_chan: self.scheduler_chan,
bluetooth_thread: self.bluetooth_thread,
@@ -529,6 +549,7 @@ impl UnprivilegedPipelineContent {
self.parent_pipeline_id.is_some(),
layout_pair,
self.pipeline_port,
+ background_hang_monitor_register,
self.layout_to_constellation_chan,
self.script_chan,
image_cache.clone(),
@@ -626,6 +647,10 @@ impl UnprivilegedPipelineContent {
}
}
+ pub fn background_hang_monitor_to_constellation_chan(&self) -> &IpcSender<HangAlert> {
+ &self.background_hang_monitor_to_constellation_chan
+ }
+
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan {
&self.script_to_constellation_chan
}