aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorbenshu <benshu@benshu.de>2015-10-23 11:54:45 +0200
committerbenshu <benshu@benshu.de>2015-11-11 00:52:34 +0100
commitd27a3244f2e77f52c62a90bf308d07e069f8390c (patch)
treec1d3da39bd4b1df3541b84cdb553aa18e5d0980b /components/script/dom/window.rs
parent13226f847234cd0130820338d5a272277780d278 (diff)
downloadservo-d27a3244f2e77f52c62a90bf308d07e069f8390c.tar.gz
servo-d27a3244f2e77f52c62a90bf308d07e069f8390c.zip
XHR timeouts use same abstraction as scripts timers. (fixes #3396)
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index e50674c222c..4da6bd76645 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -55,7 +55,7 @@ use profile_traits::mem;
use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
use script_task::{ScriptChan, ScriptPort, MainThreadScriptMsg, RunnableWrapper};
use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan, MainThreadTimerEventChan};
-use script_traits::{TimerEventChan, TimerEventId, TimerEventRequest, TimerSource};
+use script_traits::{MsDuration, TimerEventChan, TimerEventId, TimerEventRequest, TimerSource};
use selectors::parser::PseudoElement;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@@ -71,7 +71,7 @@ use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
use std::sync::mpsc::{Sender, channel};
use string_cache::Atom;
use time;
-use timers::{ActiveTimers, IsInterval, TimerCallback};
+use timers::{ActiveTimers, IsInterval, ScheduledCallback, TimerCallback, TimerHandle};
use url::Url;
use util::geometry::{self, MAX_RECT};
use util::str::{DOMString, HTML_SPACE_CHARACTERS};
@@ -1083,6 +1083,16 @@ impl Window {
self.scheduler_chan.clone()
}
+ pub fn schedule_callback(&self, callback: Box<ScheduledCallback>, duration: MsDuration) -> TimerHandle {
+ self.timers.schedule_callback(callback,
+ duration,
+ TimerSource::FromWindow(self.id.clone()))
+ }
+
+ pub fn unschedule_callback(&self, handle: TimerHandle) {
+ self.timers.unschedule_callback(handle);
+ }
+
pub fn windowproxy_handler(&self) -> WindowProxyHandler {
WindowProxyHandler(self.dom_static.windowproxy_handler.0)
}