Skip to main content

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 script_bindings::reflector::DomObject;
6use servo_base::id::PipelineId;
7use servo_constellation_traits::StructuredSerializedData;
8use servo_url::ImmutableOrigin;
9
10use crate::dom::bindings::refcounted::Trusted;
11use crate::messaging::CommonScriptMsg;
12
13/// Messages used to control the worker event loops
14pub(crate) enum WorkerScriptMsg {
15    /// Common variants associated with the script messages
16    Common(CommonScriptMsg),
17    /// Message sent through Worker.postMessage
18    DOMMessage(MessageData),
19}
20
21#[derive(MallocSizeOf)]
22pub(crate) struct MessageData {
23    pub origin: ImmutableOrigin,
24    pub data: Box<StructuredSerializedData>,
25    pub pipeline_id: PipelineId,
26}
27
28pub(crate) struct SimpleWorkerErrorHandler<T: DomObject> {
29    pub(crate) addr: Trusted<T>,
30}
31
32impl<T: DomObject> SimpleWorkerErrorHandler<T> {
33    pub(crate) fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
34        SimpleWorkerErrorHandler { addr }
35    }
36}