mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
refactor(resourcethread): expose constellationmsg channel
This commit is contained in:
parent
d1378d6bad
commit
1c465bcd66
5 changed files with 19 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -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"}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PathBuf>)
|
||||
-> (ResourceThreads, ResourceThreads) {
|
||||
let (public_core, private_core) = new_core_resource_thread(
|
||||
-> (ResourceThreads, ResourceThreads, Sender<Sender<ConstellationMsg>>) {
|
||||
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<StorageThreadMsg> = 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<PathBuf>)
|
||||
-> (CoreResourceThread, CoreResourceThread) {
|
||||
-> (CoreResourceThread, CoreResourceThread, Sender<Sender<ConstellationMsg>>) {
|
||||
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<Sender<DevtoolsControlMsg>>,
|
||||
_profiler_chan: ProfilerChan) -> CoreResourceManager {
|
||||
_profiler_chan: ProfilerChan,
|
||||
constellation_chan: Sender<ConstellationMsg>) -> CoreResourceManager {
|
||||
CoreResourceManager {
|
||||
user_agent: user_agent,
|
||||
devtools_chan: devtools_channel,
|
||||
|
|
|
@ -457,7 +457,7 @@ fn create_constellation(user_agent: Cow<'static, str>,
|
|||
-> (Sender<ConstellationMsg>, SWManagerSenders) {
|
||||
let bluetooth_thread: IpcSender<BluetoothRequest> = 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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue