Properly implement TaskSource for NetworkingTaskSource

This commit is contained in:
Keith Yeung 2016-10-13 17:41:48 -07:00
parent d99d26cf1f
commit 72cb856e31
15 changed files with 89 additions and 69 deletions

View file

@ -42,6 +42,7 @@ use std::collections::hash_map::Entry;
use std::ffi::CString;
use std::panic;
use task_source::file_reading::FileReadingTaskSource;
use task_source::networking::NetworkingTaskSource;
use time::{Timespec, get_time};
use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
use timers::{OneshotTimers, TimerCallback};
@ -325,12 +326,12 @@ impl GlobalScope {
/// `ScriptChan` to send messages to the networking task source of
/// this of this global scope.
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
pub fn networking_task_source(&self) -> NetworkingTaskSource {
if let Some(window) = self.downcast::<Window>() {
return window.networking_task_source();
}
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
return worker.script_chan();
return worker.networking_task_source();
}
unreachable!();
}