diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-16 15:36:10 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-16 15:43:33 +0200 |
commit | 9a267e53feed09ae236a554b7b58b607cdcc55d9 (patch) | |
tree | 9987278164e3dfef6f2ff36eb5b9aabe2729d340 | |
parent | 4a39631eafe8e7144a92e2c33e0688a8f3b83295 (diff) | |
download | servo-9a267e53feed09ae236a554b7b58b607cdcc55d9.tar.gz servo-9a267e53feed09ae236a554b7b58b607cdcc55d9.zip |
Send AsyncJobHandler as a MainThreadTask
-rw-r--r-- | components/script/serviceworkerjob.rs | 6 | ||||
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 16 |
2 files changed, 20 insertions, 2 deletions
diff --git a/components/script/serviceworkerjob.rs b/components/script/serviceworkerjob.rs index 483662132e4..7d92e9afde0 100644 --- a/components/script/serviceworkerjob.rs +++ b/components/script/serviceworkerjob.rs @@ -133,8 +133,10 @@ impl JobQueue { if job_queue.is_empty() { let scope_url = job.scope_url.clone(); job_queue.push(job); - let run_job_handler = box AsyncJobHandler::new(scope_url); - let _ = script_thread.dom_manipulation_task_source().queue(run_job_handler, global); + let _ = script_thread.dom_manipulation_task_source().queue_main_thread_task( + box AsyncJobHandler::new(scope_url), + global, + ); debug!("queued task to run newly-queued job"); } else { // Step 2 diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index f7b7a6577f8..0120564806c 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -6,6 +6,7 @@ use dom::bindings::inheritance::Castable; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask}; use dom::eventtarget::EventTarget; +use dom::globalscope::GlobalScope; use dom::window::Window; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use script_thread::{MainThreadScriptMsg, Task, TaskCanceller}; @@ -42,6 +43,21 @@ impl TaskSource for DOMManipulationTaskSource { } impl DOMManipulationTaskSource { + pub fn queue_main_thread_task<T>( + &self, + task: Box<T>, + global: &GlobalScope, + ) -> Result<(), ()> + where + T: Task + Send + 'static, + { + let msg = MainThreadScriptMsg::MainThreadTask( + ScriptThreadEventCategory::ScriptEvent, + global.task_canceller().wrap_task(task), + ); + self.0.send(msg).map_err(|_| ()) + } + pub fn queue_event(&self, target: &EventTarget, name: Atom, |