script/dom/
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 {
18        origin: ImmutableOrigin,
19        data: Box<StructuredSerializedData>,
20    },
21}
22
23pub(crate) struct SimpleWorkerErrorHandler<T: DomObject> {
24    pub(crate) addr: Trusted<T>,
25}
26
27impl<T: DomObject> SimpleWorkerErrorHandler<T> {
28    pub(crate) fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
29        SimpleWorkerErrorHandler { addr }
30    }
31}