aboutsummaryrefslogtreecommitdiffstats
path: root/components/constellation/pipeline.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/constellation/pipeline.rs')
-rw-r--r--components/constellation/pipeline.rs65
1 files changed, 52 insertions, 13 deletions
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index dd2a665f6ac..a75d083db64 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -28,6 +28,8 @@ use script_traits::{ConstellationControlMsg, InitialScriptState, MozBrowserEvent
use script_traits::{LayoutControlMsg, LayoutMsg, NewLayoutInfo, ScriptMsg, SWManagerMsg, SWManagerSenders};
use script_traits::{ScriptThreadFactory, TimerEventRequest, WindowSizeData};
use std::collections::HashMap;
+use std::env;
+use std::ffi::OsStr;
use std::io::Error as IOError;
use std::process;
use std::sync::mpsc::{Sender, channel};
@@ -160,6 +162,7 @@ impl Pipeline {
pipeline_port: pipeline_port,
layout_to_constellation_chan: state.layout_to_constellation_chan.clone(),
content_process_shutdown_chan: layout_content_process_shutdown_chan.clone(),
+ layout_threads: opts::get().layout_threads,
};
if let Err(e) = script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)) {
@@ -470,7 +473,8 @@ impl UnprivilegedPipelineContent {
self.time_profiler_chan,
self.mem_profiler_chan,
self.layout_content_process_shutdown_chan,
- self.webrender_api_sender);
+ self.webrender_api_sender,
+ opts::get().layout_threads);
if wait_for_completion {
let _ = self.script_content_process_shutdown_port.recv();
@@ -483,7 +487,18 @@ impl UnprivilegedPipelineContent {
use gaol::sandbox::{self, Sandbox, SandboxMethods};
use ipc_channel::ipc::IpcOneShotServer;
use sandboxing::content_process_sandbox_profile;
- use std::env;
+
+ impl CommandMethods for sandbox::Command {
+ fn arg<T>(&mut self, arg: T)
+ where T: AsRef<OsStr> {
+ self.arg(arg);
+ }
+
+ fn env<T, U>(&mut self, key: T, val: U)
+ where T: AsRef<OsStr>, U: AsRef<OsStr> {
+ self.env(key, val);
+ }
+ }
// Note that this function can panic, due to process creation,
// avoiding this panic would require a mechanism for dealing
@@ -495,11 +510,7 @@ impl UnprivilegedPipelineContent {
// If there is a sandbox, use the `gaol` API to create the child process.
let child_process = if opts::get().sandbox {
let mut command = sandbox::Command::me().expect("Failed to get current sandbox.");
- command.arg("--content-process").arg(token);
-
- if let Ok(value) = env::var("RUST_BACKTRACE") {
- command.env("RUST_BACKTRACE", value);
- }
+ self.setup_common(&mut command, token);
let profile = content_process_sandbox_profile();
ChildProcess::Sandboxed(Sandbox::new(profile).start(&mut command)
@@ -508,12 +519,7 @@ impl UnprivilegedPipelineContent {
let path_to_self = env::current_exe()
.expect("Failed to get current executor.");
let mut child_process = process::Command::new(path_to_self);
- child_process.arg("--content-process");
- child_process.arg(token);
-
- if let Ok(value) = env::var("RUST_BACKTRACE") {
- child_process.env("RUST_BACKTRACE", value);
- }
+ self.setup_common(&mut child_process, token);
ChildProcess::Unsandboxed(child_process.spawn()
.expect("Failed to start unsandboxed child process!"))
@@ -531,6 +537,19 @@ impl UnprivilegedPipelineContent {
process::exit(1);
}
+ fn setup_common<C: CommandMethods>(&self, command: &mut C, token: String) {
+ C::arg(command, "--content-process");
+ C::arg(command, token);
+
+ if let Ok(value) = env::var("RUST_BACKTRACE") {
+ C::env(command, "RUST_BACKTRACE", value);
+ }
+
+ if let Ok(value) = env::var("RUST_LOG") {
+ C::env(command, "RUST_LOG", value);
+ }
+ }
+
pub fn constellation_chan(&self) -> IpcSender<ScriptMsg> {
self.constellation_chan.clone()
}
@@ -550,3 +569,23 @@ impl UnprivilegedPipelineContent {
}
}
}
+
+trait CommandMethods {
+ fn arg<T>(&mut self, arg: T)
+ where T: AsRef<OsStr>;
+
+ fn env<T, U>(&mut self, key: T, val: U)
+ where T: AsRef<OsStr>, U: AsRef<OsStr>;
+}
+
+impl CommandMethods for process::Command {
+ fn arg<T>(&mut self, arg: T)
+ where T: AsRef<OsStr> {
+ self.arg(arg);
+ }
+
+ fn env<T, U>(&mut self, key: T, val: U)
+ where T: AsRef<OsStr>, U: AsRef<OsStr> {
+ self.env(key, val);
+ }
+}