script/dom/workers/
abstractworker.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use constellation_traits::StructuredSerializedData;
6use servo_url::ImmutableOrigin;
7
8use crate::dom::bindings::refcounted::Trusted;
9use crate::dom::bindings::reflector::DomObject;
10use crate::messaging::CommonScriptMsg;
11
12/// Messages used to control the worker event loops
13pub(crate) enum WorkerScriptMsg {
14    /// Common variants associated with the script messages
15    Common(CommonScriptMsg),
16    /// Message sent through Worker.postMessage
17    DOMMessage(MessageData),
18}
19
20#[derive(MallocSizeOf)]
21pub(crate) struct MessageData {
22    pub origin: ImmutableOrigin,
23    pub data: Box<StructuredSerializedData>,
24}
25
26pub(crate) struct SimpleWorkerErrorHandler<T: DomObject> {
27    pub(crate) addr: Trusted<T>,
28}
29
30impl<T: DomObject> SimpleWorkerErrorHandler<T> {
31    pub(crate) fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
32        SimpleWorkerErrorHandler { addr }
33    }
34}