servo/components/script/task_source/mod.rs
Keith Yeung c3b17c1201 begin messageport, transferable objects, impl
Accept transfer argument for StructuredCloneData::write

Allow structured clone reads to return a boolean

Add Transferable trait

Add basic skeletons to MessagePort

Implement transfer and transfer-receiving steps on MessagePort

Use transfer and transfer_receive in StructuredClone callbacks

Implement MessageChannel

Freeze the array object for the MessageEvent ports attribute

Implement transfer argument on window.postMessage

Use ReentrantMutex instead for MessagePortInternal

Accept origin as a parameter in dispatch_jsval

Fix BorrowMut crash with pending_port_message

Detach port on closure and check for detached during transfer

Enable webmessaging tests

fix webidl

fix
2019-10-19 14:12:22 +08:00

59 lines
1.6 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
pub mod dom_manipulation;
pub mod file_reading;
pub mod history_traversal;
pub mod media_element;
pub mod networking;
pub mod performance_timeline;
pub mod port_message;
pub mod remote_event;
pub mod user_interaction;
pub mod websocket;
use crate::dom::globalscope::GlobalScope;
use crate::task::{TaskCanceller, TaskOnce};
use enum_iterator::IntoEnumIterator;
use std::result::Result;
// 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(Clone, Eq, Hash, IntoEnumIterator, JSTraceable, PartialEq)]
pub enum TaskSourceName {
DOMManipulation,
FileReading,
HistoryTraversal,
Networking,
PerformanceTimeline,
PortMessage,
UserInteraction,
RemoteEvent,
MediaElement,
Websocket,
}
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, canceller: &TaskCanceller) -> Result<(), ()>
where
T: TaskOnce + 'static;
fn queue<T>(&self, task: T, global: &GlobalScope) -> Result<(), ()>
where
T: TaskOnce + 'static,
{
let canceller = global.task_canceller(Self::NAME);
self.queue_with_canceller(task, &canceller)
}
}