diff options
author | Gregory Terzian <gterzian@users.noreply.github.com> | 2018-07-05 12:33:09 +0800 |
---|---|---|
committer | Gregory Terzian <gterzian@users.noreply.github.com> | 2018-07-10 13:42:28 +0800 |
commit | 671627e97e20ae4baf728ae6dda61ef6f857c193 (patch) | |
tree | c86d1e568b551613bde1b61bf3db3dee42735a79 /components/script/task_source/mod.rs | |
parent | ce430566cdbccaa86ec498aa48392eab3ec69256 (diff) | |
download | servo-671627e97e20ae4baf728ae6dda61ef6f857c193.tar.gz servo-671627e97e20ae4baf728ae6dda61ef6f857c193.zip |
introduce "per task source" ignoring of tasks
Diffstat (limited to 'components/script/task_source/mod.rs')
-rw-r--r-- | components/script/task_source/mod.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index 4818ba2c80c..cf605976b46 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + pub mod dom_manipulation; pub mod file_reading; pub mod history_traversal; @@ -10,10 +11,33 @@ pub mod performance_timeline; pub mod user_interaction; use dom::globalscope::GlobalScope; +use enum_iterator::IntoEnumIterator; use std::result::Result; use task::{TaskCanceller, TaskOnce}; +// The names of all task sources, used to differentiate TaskCancellers. +// Note: When adding a task source, update this enum. +// Note: The HistoryTraversalTaskSource is not part of this, +// because it doesn't implement TaskSource. +#[derive(Eq, Hash, IntoEnumIterator, JSTraceable, PartialEq)] +pub enum TaskSourceName { + DOMManipulation, + FileReading, + HistoryTraversal, + Networking, + PerformanceTimeline, + UserInteraction +} + +impl TaskSourceName { + pub fn all() -> Vec<TaskSourceName> { + TaskSourceName::into_enum_iter().collect() + } +} + pub trait TaskSource { + const NAME: TaskSourceName; + fn queue_with_canceller<T>( &self, task: T, @@ -26,6 +50,7 @@ pub trait TaskSource { where T: TaskOnce + 'static, { - self.queue_with_canceller(task, &global.task_canceller()) + let canceller = global.task_canceller(Self::NAME); + self.queue_with_canceller(task, &canceller) } } |