mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
Remove the unneccesary thread being spawned in Browser::new.
This commit is contained in:
parent
87af57cefc
commit
833e0a399b
1 changed files with 38 additions and 54 deletions
|
@ -50,10 +50,6 @@ use util::taskpool::TaskPool;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
#[cfg(not(test))]
|
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
#[cfg(not(test))]
|
|
||||||
use std::thread::Builder;
|
|
||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
compositor: Box<CompositorEventListener + 'static>,
|
compositor: Box<CompositorEventListener + 'static>,
|
||||||
|
@ -79,59 +75,47 @@ impl Browser {
|
||||||
devtools::start_server(port)
|
devtools::start_server(port)
|
||||||
});
|
});
|
||||||
|
|
||||||
let opts_clone = opts.clone();
|
// Create a Servo instance.
|
||||||
let time_profiler_chan_clone = time_profiler_chan.clone();
|
let resource_task = new_resource_task(opts.user_agent.clone());
|
||||||
let memory_profiler_chan_clone = memory_profiler_chan.clone();
|
|
||||||
|
|
||||||
let (result_chan, result_port) = channel();
|
// If we are emitting an output file, then we need to block on
|
||||||
let compositor_proxy_for_constellation = compositor_proxy.clone_compositor_proxy();
|
// image load or we risk emitting an output file missing the
|
||||||
Builder::new()
|
// image.
|
||||||
.spawn(move || {
|
let image_cache_task = if opts.output_file.is_some() {
|
||||||
let opts = &opts_clone;
|
ImageCacheTask::new_sync(resource_task.clone(), shared_task_pool,
|
||||||
// Create a Servo instance.
|
time_profiler_chan.clone())
|
||||||
let resource_task = new_resource_task(opts.user_agent.clone());
|
} else {
|
||||||
// If we are emitting an output file, then we need to block on
|
ImageCacheTask::new(resource_task.clone(), shared_task_pool,
|
||||||
// image load or we risk emitting an output file missing the
|
time_profiler_chan.clone())
|
||||||
// image.
|
};
|
||||||
let image_cache_task = if opts.output_file.is_some() {
|
|
||||||
ImageCacheTask::new_sync(resource_task.clone(), shared_task_pool,
|
let font_cache_task = FontCacheTask::new(resource_task.clone());
|
||||||
time_profiler_chan_clone.clone())
|
let storage_task: StorageTask = StorageTaskFactory::new();
|
||||||
} else {
|
|
||||||
ImageCacheTask::new(resource_task.clone(), shared_task_pool,
|
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
||||||
time_profiler_chan_clone.clone())
|
script::script_task::ScriptTask>::start(
|
||||||
|
compositor_proxy.clone_compositor_proxy(),
|
||||||
|
resource_task,
|
||||||
|
image_cache_task,
|
||||||
|
font_cache_task,
|
||||||
|
time_profiler_chan.clone(),
|
||||||
|
memory_profiler_chan.clone(),
|
||||||
|
devtools_chan,
|
||||||
|
storage_task);
|
||||||
|
|
||||||
|
// Send the URL command to the constellation.
|
||||||
|
let cwd = env::current_dir().unwrap();
|
||||||
|
for url in opts.urls.iter() {
|
||||||
|
let url = match url::Url::parse(&*url) {
|
||||||
|
Ok(url) => url,
|
||||||
|
Err(url::ParseError::RelativeUrlWithoutBase)
|
||||||
|
=> url::Url::from_file_path(&*cwd.join(&*url)).unwrap(),
|
||||||
|
Err(_) => panic!("URL parsing failed"),
|
||||||
};
|
};
|
||||||
let font_cache_task = FontCacheTask::new(resource_task.clone());
|
|
||||||
let storage_task: StorageTask = StorageTaskFactory::new();
|
|
||||||
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
|
||||||
script::script_task::ScriptTask>::start(
|
|
||||||
compositor_proxy_for_constellation,
|
|
||||||
resource_task,
|
|
||||||
image_cache_task,
|
|
||||||
font_cache_task,
|
|
||||||
time_profiler_chan_clone,
|
|
||||||
memory_profiler_chan_clone,
|
|
||||||
devtools_chan,
|
|
||||||
storage_task);
|
|
||||||
|
|
||||||
// Send the URL command to the constellation.
|
let ConstellationChan(ref chan) = constellation_chan;
|
||||||
let cwd = env::current_dir().unwrap();
|
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||||
for url in opts.urls.iter() {
|
}
|
||||||
let url = match url::Url::parse(&*url) {
|
|
||||||
Ok(url) => url,
|
|
||||||
Err(url::ParseError::RelativeUrlWithoutBase)
|
|
||||||
=> url::Url::from_file_path(&*cwd.join(&*url)).unwrap(),
|
|
||||||
Err(_) => panic!("URL parsing failed"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let ConstellationChan(ref chan) = constellation_chan;
|
|
||||||
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the constallation Chan as the result
|
|
||||||
result_chan.send(constellation_chan).unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
let constellation_chan = result_port.recv().unwrap();
|
|
||||||
|
|
||||||
debug!("preparing to enter main loop");
|
debug!("preparing to enter main loop");
|
||||||
let compositor = CompositorTask::create(window,
|
let compositor = CompositorTask::create(window,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue