Introduce GlobalScope::file_reading_task_source

This commit is contained in:
Anthony Ramine 2016-10-05 09:52:30 +02:00
parent 0a11c48e89
commit e7a1149984
3 changed files with 17 additions and 13 deletions

View file

@ -36,6 +36,7 @@ use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::ffi::CString;
use std::panic;
use task_source::file_reading::FileReadingTaskSource;
use time::{Timespec, get_time};
use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
use timers::{OneshotTimers, TimerCallback};
@ -457,6 +458,18 @@ impl GlobalScope {
}
unreachable!();
}
/// Channel to send messages to the file reading task source of
/// this of this global scope.
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
if let Some(window) = self.downcast::<Window>() {
return window.file_reading_task_source();
}
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
return worker.file_reading_task_source();
}
unreachable!();
}
}
fn timestamp_in_ms(time: Timespec) -> u64 {