mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
compositing: Split Servo up into multiple sandboxed processes.
Multiprocess mode is enabled with the `-M` switch, and sandboxing is enabled with the `-S` switch.
This commit is contained in:
parent
ff4171170d
commit
1c130819ca
33 changed files with 688 additions and 265 deletions
|
@ -17,6 +17,8 @@
|
|||
// The `Browser` is fed events from a generic type that implements the
|
||||
// `WindowMethods` trait.
|
||||
|
||||
extern crate gaol;
|
||||
|
||||
#[macro_use]
|
||||
extern crate util as _util;
|
||||
|
||||
|
@ -29,6 +31,7 @@ mod export {
|
|||
extern crate euclid;
|
||||
extern crate gfx;
|
||||
extern crate gleam;
|
||||
extern crate ipc_channel;
|
||||
extern crate layers;
|
||||
extern crate layout;
|
||||
extern crate msg;
|
||||
|
@ -48,22 +51,25 @@ extern crate libc;
|
|||
extern crate webdriver_server;
|
||||
|
||||
#[cfg(feature = "webdriver")]
|
||||
fn webdriver(port: u16, constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) {
|
||||
webdriver_server::start_server(port, constellation.clone());
|
||||
fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
|
||||
webdriver_server::start_server(port, constellation);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "webdriver"))]
|
||||
fn webdriver(_port: u16, _constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) { }
|
||||
fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
|
||||
|
||||
use compositing::CompositorEventListener;
|
||||
use compositing::compositor_task::InitialCompositorState;
|
||||
use compositing::constellation::InitialConstellationState;
|
||||
use compositing::pipeline::UnprivilegedPipelineContent;
|
||||
use compositing::sandboxing;
|
||||
use compositing::windowing::WindowEvent;
|
||||
use compositing::windowing::WindowMethods;
|
||||
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
||||
use gaol::sandbox::{ChildSandbox, ChildSandboxMethods};
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use msg::constellation_msg::CompositorMsg as ConstellationMsg;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use net::image_cache_task::new_image_cache_task;
|
||||
use net::resource_task::new_resource_task;
|
||||
use net::storage_task::StorageTaskFactory;
|
||||
|
@ -86,6 +92,7 @@ pub use export::devtools_traits;
|
|||
pub use export::euclid;
|
||||
pub use export::gfx;
|
||||
pub use export::gleam::gl;
|
||||
pub use export::ipc_channel;
|
||||
pub use export::layers;
|
||||
pub use export::layout;
|
||||
pub use export::msg;
|
||||
|
@ -193,7 +200,7 @@ fn create_constellation(opts: opts::Opts,
|
|||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
||||
supports_clipboard: bool) -> ConstellationChan<ConstellationMsg> {
|
||||
supports_clipboard: bool) -> Sender<ConstellationMsg> {
|
||||
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||
|
||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||
|
@ -218,11 +225,33 @@ fn create_constellation(opts: opts::Opts,
|
|||
// Send the URL command to the constellation.
|
||||
match opts.url {
|
||||
Some(url) => {
|
||||
let ConstellationChan(ref chan) = constellation_chan;
|
||||
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||
constellation_chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||
},
|
||||
None => ()
|
||||
};
|
||||
|
||||
constellation_chan
|
||||
}
|
||||
|
||||
/// Content process entry point.
|
||||
pub fn run_content_process(token: String) {
|
||||
let (unprivileged_content_sender, unprivileged_content_receiver) =
|
||||
ipc::channel::<UnprivilegedPipelineContent>().unwrap();
|
||||
let connection_bootstrap: IpcSender<IpcSender<UnprivilegedPipelineContent>> =
|
||||
IpcSender::connect(token).unwrap();
|
||||
connection_bootstrap.send(unprivileged_content_sender).unwrap();
|
||||
|
||||
let unprivileged_content = unprivileged_content_receiver.recv().unwrap();
|
||||
opts::set_defaults(unprivileged_content.opts());
|
||||
|
||||
// Enter the sandbox if necessary.
|
||||
if opts::get().sandbox {
|
||||
ChildSandbox::new(sandboxing::content_process_sandbox_profile()).activate().unwrap();
|
||||
}
|
||||
|
||||
script::init();
|
||||
|
||||
unprivileged_content.start_all::<layout::layout_task::LayoutTask,
|
||||
script::script_task::ScriptTask>(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue