aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/workerglobalscope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/workerglobalscope.rs')
-rw-r--r--components/script/dom/workerglobalscope.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 79d52a9ff99..f328e0a127c 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -114,15 +114,14 @@ pub struct WorkerGlobalScope {
#[ignore_malloc_size_of = "Defined in ipc-channel"]
#[no_trace]
- /// Optional `IpcSender` for sending the `DevtoolScriptControlMsg`
- /// to the server from within the worker
- from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
+ /// A `Sender` for sending messages to devtools. This is unused but is stored here to
+ /// keep the channel alive.
+ _devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
- #[ignore_malloc_size_of = "Defined in std"]
+ #[ignore_malloc_size_of = "Defined in crossbeam"]
#[no_trace]
- /// This `Receiver` will be ignored later if the corresponding
- /// `IpcSender` doesn't exist
- from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
+ /// A `Receiver` for receiving messages from devtools.
+ devtools_receiver: Option<Receiver<DevtoolScriptControlMsg>>,
#[no_trace]
navigation_start: CrossProcessInstant,
@@ -137,12 +136,18 @@ impl WorkerGlobalScope {
worker_type: WorkerType,
worker_url: ServoUrl,
runtime: Runtime,
- from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
+ devtools_receiver: Receiver<DevtoolScriptControlMsg>,
closing: Arc<AtomicBool>,
gpu_id_hub: Arc<IdentityHub>,
) -> Self {
// Install a pipeline-namespace in the current thread.
PipelineNamespace::auto_install();
+
+ let devtools_receiver = match init.from_devtools_sender {
+ Some(..) => Some(devtools_receiver),
+ None => None,
+ };
+
Self {
globalscope: GlobalScope::new_inherited(
init.pipeline_id,
@@ -168,8 +173,8 @@ impl WorkerGlobalScope {
runtime: DomRefCell::new(Some(runtime)),
location: Default::default(),
navigator: Default::default(),
- from_devtools_sender: init.from_devtools_sender,
- from_devtools_receiver,
+ devtools_receiver,
+ _devtools_sender: init.from_devtools_sender,
navigation_start: CrossProcessInstant::now(),
performance: Default::default(),
}
@@ -193,12 +198,8 @@ impl WorkerGlobalScope {
.prepare_for_new_child()
}
- pub fn from_devtools_sender(&self) -> Option<IpcSender<DevtoolScriptControlMsg>> {
- self.from_devtools_sender.clone()
- }
-
- pub fn from_devtools_receiver(&self) -> &Receiver<DevtoolScriptControlMsg> {
- &self.from_devtools_receiver
+ pub fn devtools_receiver(&self) -> Option<&Receiver<DevtoolScriptControlMsg>> {
+ self.devtools_receiver.as_ref()
}
#[allow(unsafe_code)]