use remote-event task source in EventSource

This commit is contained in:
Gregory Terzian 2018-07-12 23:13:50 +08:00
parent f66c9b6160
commit baef63becd
7 changed files with 81 additions and 8 deletions

View file

@ -56,6 +56,7 @@ use task_source::TaskSourceName;
use task_source::file_reading::FileReadingTaskSource;
use task_source::networking::NetworkingTaskSource;
use task_source::performance_timeline::PerformanceTimelineTaskSource;
use task_source::remote_event::RemoteEventTaskSource;
use time::{Timespec, get_time};
use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
use timers::{OneshotTimers, TimerCallback};
@ -390,7 +391,7 @@ impl GlobalScope {
}
/// `ScriptChan` to send messages to the networking task source of
/// this of this global scope.
/// this global scope.
pub fn networking_task_source(&self) -> NetworkingTaskSource {
if let Some(window) = self.downcast::<Window>() {
return window.networking_task_source();
@ -401,6 +402,18 @@ impl GlobalScope {
unreachable!();
}
/// `ScriptChan` to send messages to the remote-event task source of
/// this global scope.
pub fn remote_event_task_source(&self) -> RemoteEventTaskSource {
if let Some(window) = self.downcast::<Window>() {
return window.remote_event_task_source();
}
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
return worker.remote_event_task_source();
}
unreachable!();
}
/// Evaluate JS code on this global scope.
pub fn evaluate_js_on_global_with_result(
&self, code: &str, rval: MutableHandleValue) -> bool {