mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove uses of AsyncJobHandler from script_thread
This commit is contained in:
parent
f58207b851
commit
1d52df0562
2 changed files with 11 additions and 13 deletions
|
@ -98,7 +98,7 @@ use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType};
|
||||||
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
|
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
|
||||||
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
|
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
|
||||||
use script_traits::webdriver_msg::WebDriverScriptCommand;
|
use script_traits::webdriver_msg::WebDriverScriptCommand;
|
||||||
use serviceworkerjob::{Job, JobQueue, AsyncJobHandler};
|
use serviceworkerjob::{Job, JobQueue};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
|
@ -1787,8 +1787,8 @@ impl ScriptThread {
|
||||||
let _ = self.script_sender.send((pipeline_id, ScriptMsg::RegisterServiceWorker(scope_things, scope.clone())));
|
let _ = self.script_sender.send((pipeline_id, ScriptMsg::RegisterServiceWorker(scope_things, scope.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_job_queue(&self, job_handler: Box<AsyncJobHandler>) {
|
pub fn dispatch_job_queue(&self, scope_url: ServoUrl) {
|
||||||
self.job_queue_map.run_job(job_handler, self);
|
self.job_queue_map.run_job(scope_url, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dom_manipulation_task_source(&self) -> &DOMManipulationTaskSource {
|
pub fn dom_manipulation_task_source(&self) -> &DOMManipulationTaskSource {
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl AsyncJobHandler {
|
||||||
impl Task for AsyncJobHandler {
|
impl Task for AsyncJobHandler {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn run_with_script_thread(self: Box<AsyncJobHandler>, script_thread: &ScriptThread) {
|
fn run_with_script_thread(self: Box<AsyncJobHandler>, script_thread: &ScriptThread) {
|
||||||
script_thread.dispatch_job_queue(self);
|
script_thread.dispatch_job_queue(self.scope_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,30 +157,29 @@ impl JobQueue {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://w3c.github.io/ServiceWorker/#run-job-algorithm
|
// https://w3c.github.io/ServiceWorker/#run-job-algorithm
|
||||||
pub fn run_job(&self, run_job_handler: Box<AsyncJobHandler>, script_thread: &ScriptThread) {
|
pub fn run_job(&self, scope_url: ServoUrl, script_thread: &ScriptThread) {
|
||||||
debug!("running a job");
|
debug!("running a job");
|
||||||
let url = {
|
let url = {
|
||||||
let queue_ref = self.0.borrow();
|
let queue_ref = self.0.borrow();
|
||||||
let front_job = {
|
let front_job = {
|
||||||
let job_vec = queue_ref.get(&run_job_handler.scope_url);
|
let job_vec = queue_ref.get(&scope_url);
|
||||||
job_vec.unwrap().first().unwrap()
|
job_vec.unwrap().first().unwrap()
|
||||||
};
|
};
|
||||||
let scope_url = front_job.scope_url.clone();
|
let front_scope_url = front_job.scope_url.clone();
|
||||||
match front_job.job_type {
|
match front_job.job_type {
|
||||||
JobType::Register => self.run_register(front_job, run_job_handler, script_thread),
|
JobType::Register => self.run_register(front_job, scope_url, script_thread),
|
||||||
JobType::Update => self.update(front_job, script_thread),
|
JobType::Update => self.update(front_job, script_thread),
|
||||||
JobType::Unregister => unreachable!(),
|
JobType::Unregister => unreachable!(),
|
||||||
};
|
};
|
||||||
scope_url
|
front_scope_url
|
||||||
};
|
};
|
||||||
self.finish_job(url, script_thread);
|
self.finish_job(url, script_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
// https://w3c.github.io/ServiceWorker/#register-algorithm
|
// https://w3c.github.io/ServiceWorker/#register-algorithm
|
||||||
fn run_register(&self, job: &Job, register_job_handler: Box<AsyncJobHandler>, script_thread: &ScriptThread) {
|
fn run_register(&self, job: &Job, scope_url: ServoUrl, script_thread: &ScriptThread) {
|
||||||
debug!("running register job");
|
debug!("running register job");
|
||||||
let AsyncJobHandler { scope_url, .. } = *register_job_handler;
|
|
||||||
// Step 1-3
|
// Step 1-3
|
||||||
if !UrlHelper::is_origin_trustworthy(&job.script_url) {
|
if !UrlHelper::is_origin_trustworthy(&job.script_url) {
|
||||||
// Step 1.1
|
// Step 1.1
|
||||||
|
@ -239,8 +238,7 @@ impl JobQueue {
|
||||||
|
|
||||||
if run_job {
|
if run_job {
|
||||||
debug!("further jobs in queue after finishing");
|
debug!("further jobs in queue after finishing");
|
||||||
let handler = box AsyncJobHandler::new(scope_url);
|
self.run_job(scope_url, script_thread);
|
||||||
self.run_job(handler, script_thread);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue