diff --git a/Cargo.lock b/Cargo.lock index c6002808308..d2c1c8c77bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1910,6 +1910,7 @@ dependencies = [ "net_traits 0.0.1", "openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", "profile_traits 0.0.1", + "script_traits 0.0.1", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo-websocket 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 4fdee627ca9..5e747577ada 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -34,6 +34,7 @@ msg = {path = "../msg"} net_traits = {path = "../net_traits"} openssl = "0.9" profile_traits = {path = "../profile_traits"} +script_traits = {path = "../script_traits"} serde = "1.0" serde_json = "1.0" servo_allocator = {path = "../allocator"} diff --git a/components/net/lib.rs b/components/net/lib.rs index 1bc43b361f4..1e17fd0988d 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -29,6 +29,7 @@ extern crate net_traits; extern crate openssl; #[macro_use] extern crate profile_traits; +extern crate script_traits; #[macro_use] extern crate serde; extern crate serde_json; extern crate servo_allocator; diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index 5e708465bf7..a7715e1fdf7 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -28,6 +28,7 @@ use net_traits::storage_thread::StorageThreadMsg; use profile_traits::mem::{Report, ReportsChan, ReportKind}; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan; +use script_traits::ConstellationMsg; use serde::{Deserialize, Serialize}; use serde_json; use servo_allocator; @@ -41,7 +42,7 @@ use std::io::prelude::*; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, RwLock}; -use std::sync::mpsc::Sender; +use std::sync::mpsc::{self, Sender}; use std::thread; use storage_thread::StorageThreadFactory; use websocket_loader; @@ -54,8 +55,8 @@ pub fn new_resource_threads(user_agent: Cow<'static, str>, time_profiler_chan: ProfilerChan, mem_profiler_chan: MemProfilerChan, config_dir: Option) - -> (ResourceThreads, ResourceThreads) { - let (public_core, private_core) = new_core_resource_thread( + -> (ResourceThreads, ResourceThreads, Sender>) { + let (public_core, private_core, constellation_sender) = new_core_resource_thread( user_agent, devtools_chan, time_profiler_chan, @@ -63,7 +64,8 @@ pub fn new_resource_threads(user_agent: Cow<'static, str>, config_dir.clone()); let storage: IpcSender = StorageThreadFactory::new(config_dir); (ResourceThreads::new(public_core, storage.clone()), - ResourceThreads::new(private_core, storage)) + ResourceThreads::new(private_core, storage), + constellation_sender) } @@ -73,14 +75,16 @@ pub fn new_core_resource_thread(user_agent: Cow<'static, str>, time_profiler_chan: ProfilerChan, mem_profiler_chan: MemProfilerChan, config_dir: Option) - -> (CoreResourceThread, CoreResourceThread) { + -> (CoreResourceThread, CoreResourceThread, Sender>) { let (public_setup_chan, public_setup_port) = ipc::channel().unwrap(); let (private_setup_chan, private_setup_port) = ipc::channel().unwrap(); let (report_chan, report_port) = ipc::channel().unwrap(); + let (constellation_sender, constellation_receiver) = mpsc::channel(); thread::Builder::new().name("ResourceManager".to_owned()).spawn(move || { + let constellation_chan = constellation_receiver.recv().unwrap(); let resource_manager = CoreResourceManager::new( - user_agent, devtools_chan, time_profiler_chan + user_agent, devtools_chan, time_profiler_chan, constellation_chan ); let mut channel_manager = ResourceChannelManager { @@ -99,7 +103,7 @@ pub fn new_core_resource_thread(user_agent: Cow<'static, str>, |report_chan| report_chan); }).expect("Thread spawning failed"); - (public_setup_chan, private_setup_chan) + (public_setup_chan, private_setup_chan, constellation_sender) } struct ResourceChannelManager { @@ -374,7 +378,8 @@ pub struct CoreResourceManager { impl CoreResourceManager { pub fn new(user_agent: Cow<'static, str>, devtools_channel: Option>, - _profiler_chan: ProfilerChan) -> CoreResourceManager { + _profiler_chan: ProfilerChan, + constellation_chan: Sender) -> CoreResourceManager { CoreResourceManager { user_agent: user_agent, devtools_chan: devtools_channel, diff --git a/components/servo/lib.rs b/components/servo/lib.rs index e0e8f41b1b3..4fd94207b47 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -457,7 +457,7 @@ fn create_constellation(user_agent: Cow<'static, str>, -> (Sender, SWManagerSenders) { let bluetooth_thread: IpcSender = BluetoothThreadFactory::new(embedder_proxy.clone()); - let (public_resource_threads, private_resource_threads) = + let (public_resource_threads, private_resource_threads, resource_constellation_sender) = new_resource_threads(user_agent, devtools_chan.clone(), time_profiler_chan.clone(), @@ -533,6 +533,8 @@ fn create_constellation(user_agent: Cow<'static, str>, webvr_constellation_sender.send(constellation_chan.clone()).unwrap(); } + resource_constellation_sender.send(constellation_chan.clone()).unwrap(); + // channels to communicate with Service Worker Manager let sw_senders = SWManagerSenders { swmanager_sender: from_swmanager_sender,