Integrate service worker manager thread

This commit is contained in:
Rahul Sharma 2016-06-09 18:52:52 +05:30
parent e8fa02a07f
commit 1e6293ea1d
39 changed files with 764 additions and 582 deletions

View file

@ -83,7 +83,7 @@ use profile::mem as profile_mem;
use profile::time as profile_time;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{ConstellationMsg, ScriptMsg};
use script_traits::{ConstellationMsg, ScriptMsg, SWManagerMsg};
use std::cmp::max;
use std::rc::Rc;
use std::sync::mpsc::Sender;
@ -114,7 +114,6 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
// Global configuration options, parsed from the command line.
let opts = opts::get();
script::init();
// Get both endpoints of a special channel for communication between
// the client window and the compositor. This channel is unique because
@ -160,13 +159,16 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
// Create the constellation, which maintains the engine
// pipelines, including the script and layout threads, as well
// as the navigation context.
let constellation_chan = create_constellation(opts.clone(),
compositor_proxy.clone_compositor_proxy(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
devtools_chan,
supports_clipboard,
webrender_api_sender.clone());
let (constellation_chan, swmanager_sender) = create_constellation(opts.clone(),
compositor_proxy.clone_compositor_proxy(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
devtools_chan,
supports_clipboard,
webrender_api_sender.clone());
// Send the constellation's swmanager sender to service worker manager thread
script::init(swmanager_sender);
if cfg!(feature = "webdriver") {
if let Some(port) = opts.webdriver_port {
@ -227,7 +229,8 @@ fn create_constellation(opts: opts::Opts,
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
supports_clipboard: bool,
webrender_api_sender: Option<webrender_traits::RenderApiSender>) -> Sender<ConstellationMsg> {
webrender_api_sender: Option<webrender_traits::RenderApiSender>)
-> (Sender<ConstellationMsg>, IpcSender<SWManagerMsg>) {
let bluetooth_thread: IpcSender<BluetoothMethodMsg> = BluetoothThreadFactory::new();
let (public_resource_threads, private_resource_threads) =
@ -252,7 +255,7 @@ fn create_constellation(opts: opts::Opts,
supports_clipboard: supports_clipboard,
webrender_api_sender: webrender_api_sender,
};
let constellation_chan =
let (constellation_chan, from_swmanager_sender) =
Constellation::<script_layout_interface::message::Msg,
layout_thread::LayoutThread,
script::script_thread::ScriptThread>::start(initial_state);
@ -261,7 +264,7 @@ fn create_constellation(opts: opts::Opts,
constellation_chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
};
constellation_chan
(constellation_chan, from_swmanager_sender)
}
// A logger that logs to two downstream loggers.
@ -308,7 +311,9 @@ pub fn run_content_process(token: String) {
create_sandbox();
}
script::init();
// Send the constellation sender to service worker manager thread
let from_swmanager_sender = unprivileged_content.swmanager_chan();
script::init(from_swmanager_sender);
unprivileged_content.start_all::<script_layout_interface::message::Msg,
layout_thread::LayoutThread,