mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce GlobalScope::enqueue_promise_job
This commit is contained in:
parent
2ee073053a
commit
4d9347d5b3
4 changed files with 20 additions and 17 deletions
|
@ -26,7 +26,7 @@ use libc;
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
||||
use profile_traits::{mem, time};
|
||||
use script_runtime::{ScriptChan, maybe_take_panic_result};
|
||||
use script_runtime::{EnqueuedPromiseCallback, ScriptChan, maybe_take_panic_result};
|
||||
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
|
||||
use script_traits::{TimerEventId, TimerEventRequest, TimerSource};
|
||||
|
@ -420,6 +420,17 @@ impl GlobalScope {
|
|||
}
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
/// Enqueue a promise callback for subsequent execution.
|
||||
pub fn enqueue_promise_job(&self, job: EnqueuedPromiseCallback) {
|
||||
if self.is::<Window>() {
|
||||
return ScriptThread::enqueue_promise_job(job, self);
|
||||
}
|
||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||
return worker.enqueue_promise_job(job);
|
||||
}
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue