mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
XHR timeouts use same abstraction as scripts timers. (fixes #3396)
This commit is contained in:
parent
13226f8472
commit
d27a3244f2
6 changed files with 139 additions and 49 deletions
|
@ -24,12 +24,12 @@ use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
|
|||
use net_traits::{ResourceTask, load_whole_resource};
|
||||
use profile_traits::mem;
|
||||
use script_task::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_traits::{TimerEventChan, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use script_traits::{MsDuration, TimerEventChan, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use timers::{ActiveTimers, IsInterval, TimerCallback};
|
||||
use timers::{ActiveTimers, IsInterval, ScheduledCallback, TimerCallback, TimerHandle};
|
||||
use url::{Url, UrlParser};
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -143,6 +143,16 @@ impl WorkerGlobalScope {
|
|||
self.scheduler_chan.clone()
|
||||
}
|
||||
|
||||
pub fn schedule_callback(&self, callback: Box<ScheduledCallback>, duration: MsDuration) -> TimerHandle {
|
||||
self.timers.schedule_callback(callback,
|
||||
duration,
|
||||
TimerSource::FromWorker)
|
||||
}
|
||||
|
||||
pub fn unschedule_callback(&self, handle: TimerHandle) {
|
||||
self.timers.unschedule_callback(handle);
|
||||
}
|
||||
|
||||
pub fn get_cx(&self) -> *mut JSContext {
|
||||
self.runtime.cx()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue