aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-07-24 17:00:10 -0700
committerJosh Matthews <josh@joshmatthews.net>2015-11-19 16:38:04 -0500
commit1c130819ca6fdcef66495ea3dabf9d9575774d52 (patch)
treed5c58d9891ee0958aeeffdb04f86fd813fe0a4c3 /components/script/script_task.rs
parentff4171170dba925b9036bf59af7dc17202273af1 (diff)
downloadservo-1c130819ca6fdcef66495ea3dabf9d9575774d52.tar.gz
servo-1c130819ca6fdcef66495ea3dabf9d9575774d52.zip
compositing: Split Servo up into multiple sandboxed processes.
Multiprocess mode is enabled with the `-M` switch, and sandboxing is enabled with the `-S` switch.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 5f881601bd7..043c0574be1 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -104,7 +104,7 @@ use time::{Tm, now};
use url::{Url, UrlParser};
use util::opts;
use util::str::DOMString;
-use util::task::spawn_named_with_send_on_failure;
+use util::task;
use util::task_state;
use webdriver_handlers;
@@ -232,8 +232,9 @@ pub enum ScriptTaskEventCategory {
Resize,
ScriptEvent,
TimerEvent,
- UpdateReplacedElement,
SetViewport,
+ StylesheetLoad,
+ UpdateReplacedElement,
WebSocketEvent,
WorkerEvent,
}
@@ -396,7 +397,7 @@ pub struct ScriptTask {
chan: MainThreadScriptChan,
/// A channel to hand out to tasks that need to respond to a message from the script task.
- control_chan: Sender<ConstellationControlMsg>,
+ control_chan: IpcSender<ConstellationControlMsg>,
/// The port on which the constellation and layout tasks can communicate with the
/// script task.
@@ -438,6 +439,8 @@ pub struct ScriptTask {
scheduler_chan: IpcSender<TimerEventRequest>,
timer_event_chan: Sender<TimerEvent>,
timer_event_port: Receiver<TimerEvent>,
+
+ content_process_shutdown_chan: IpcSender<()>,
}
/// In the event of task failure, all data on the stack runs its destructor. However, there
@@ -484,7 +487,8 @@ impl ScriptTaskFactory for ScriptTask {
ScriptLayoutChan::new(chan, port)
}
- fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel) -> Box<Any + Send> {
+ fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel)
+ -> Box<Any + Send> {
box pair.sender() as Box<Any + Send>
}
@@ -496,9 +500,10 @@ impl ScriptTaskFactory for ScriptTask {
let (script_chan, script_port) = channel();
let layout_chan = LayoutChan(layout_chan.sender());
let failure_info = state.failure_info;
- spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id), task_state::SCRIPT, move || {
+ task::spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id),
+ task_state::SCRIPT,
+ move || {
PipelineNamespace::install(state.pipeline_namespace_id);
-
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
let chan = MainThreadScriptChan(script_chan);
@@ -524,6 +529,7 @@ impl ScriptTaskFactory for ScriptTask {
let reporter_name = format!("script-reporter-{}", id);
mem_profiler_chan.run_with_memory_reporting(|| {
script_task.start();
+ let _ = script_task.content_process_shutdown_chan.send(());
}, reporter_name, channel_for_reporter, CommonScriptMsg::CollectReports);
// This must always be the very last operation performed before the task completes
@@ -636,6 +642,9 @@ impl ScriptTask {
let (timer_event_chan, timer_event_port) = channel();
+ // Ask the router to proxy IPC messages from the control port to us.
+ let control_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(state.control_port);
+
ScriptTask {
page: DOMRefCell::new(None),
incomplete_loads: DOMRefCell::new(vec!()),
@@ -650,7 +659,7 @@ impl ScriptTask {
port: port,
chan: chan,
control_chan: state.control_chan,
- control_port: state.control_port,
+ control_port: control_port,
constellation_chan: state.constellation_chan,
compositor: DOMRefCell::new(state.compositor),
time_profiler_chan: state.time_profiler_chan,
@@ -667,6 +676,8 @@ impl ScriptTask {
scheduler_chan: state.scheduler_chan,
timer_event_chan: timer_event_chan,
timer_event_port: timer_event_port,
+
+ content_process_shutdown_chan: state.content_process_shutdown_chan,
}
}
@@ -940,7 +951,10 @@ impl ScriptTask {
ScriptTaskEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent,
ScriptTaskEventCategory::Resize => ProfilerCategory::ScriptResize,
ScriptTaskEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent,
- ScriptTaskEventCategory::UpdateReplacedElement => ProfilerCategory::ScriptUpdateReplacedElement,
+ ScriptTaskEventCategory::UpdateReplacedElement => {
+ ProfilerCategory::ScriptUpdateReplacedElement
+ }
+ ScriptTaskEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad,
ScriptTaskEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport,
ScriptTaskEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent,
ScriptTaskEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent,
@@ -1185,6 +1199,7 @@ impl ScriptTask {
failure,
pipeline_port,
layout_shutdown_chan,
+ content_process_shutdown_chan,
} = new_layout_info;
let layout_pair = ScriptTask::create_layout_channel(None::<&mut ScriptTask>);
@@ -1204,6 +1219,7 @@ impl ScriptTask {
script_chan: self.control_chan.clone(),
image_cache_task: self.image_cache_task.clone(),
layout_shutdown_chan: layout_shutdown_chan,
+ content_process_shutdown_chan: content_process_shutdown_chan,
};
let page = self.root_page();