mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
constellation: Rename messages sent to the Constellation
(#36341)
Messages that are sent to the `Constellation` have pretty ambiguous names. This change does two renames: - `ConstellationMsg` → `EmbedderToConstellationMessage` - `ScriptMsg` → `ScriptToConstellationMessage` This naming reflects that the `Constellation` stands in between the embedding layer and the script layer and can receive messages from both. Soon both of these message types will live in `constellation_traits`, reflecting the idea that the `_traits` variant for a crate is responsible for exposing the API for that crate. Testing: No new tests are necessary here as this just renames two enums. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c7a7862574
commit
5a35e1faec
37 changed files with 415 additions and 364 deletions
|
@ -58,7 +58,8 @@ use script_bindings::interfaces::GlobalScopeHelpers;
|
|||
use script_traits::serializable::{BlobData, BlobImpl, FileBlob};
|
||||
use script_traits::transferable::MessagePortImpl;
|
||||
use script_traits::{
|
||||
BroadcastMsg, MessagePortMsg, PortMessageTask, ScriptMsg, ScriptToConstellationChan,
|
||||
BroadcastMsg, MessagePortMsg, PortMessageTask, ScriptToConstellationChan,
|
||||
ScriptToConstellationMessage,
|
||||
};
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use timers::{TimerEventId, TimerEventRequest, TimerSource};
|
||||
|
@ -526,7 +527,7 @@ impl MessageListener {
|
|||
// If not managing any ports, no transfer can succeed,
|
||||
// so just send back everything.
|
||||
let _ = global.script_to_constellation_chan().send(
|
||||
ScriptMsg::MessagePortTransferResult(None, vec![], ports),
|
||||
ScriptToConstellationMessage::MessagePortTransferResult(None, vec![], ports),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -544,7 +545,7 @@ impl MessageListener {
|
|||
}
|
||||
}
|
||||
let _ = global.script_to_constellation_chan().send(
|
||||
ScriptMsg::MessagePortTransferResult(Some(router_id), succeeded, failed),
|
||||
ScriptToConstellationMessage::MessagePortTransferResult(Some(router_id), succeeded, failed),
|
||||
);
|
||||
})
|
||||
);
|
||||
|
@ -916,9 +917,9 @@ impl GlobalScope {
|
|||
if let MessagePortState::Managed(router_id, _message_ports) =
|
||||
&*self.message_port_state.borrow()
|
||||
{
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::RemoveMessagePortRouter(*router_id));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::RemoveMessagePortRouter(*router_id),
|
||||
);
|
||||
}
|
||||
*self.message_port_state.borrow_mut() = MessagePortState::UnManaged;
|
||||
}
|
||||
|
@ -929,12 +930,12 @@ impl GlobalScope {
|
|||
if let BroadcastChannelState::Managed(router_id, _channels) =
|
||||
&*self.broadcast_channel_state.borrow()
|
||||
{
|
||||
let _ =
|
||||
self.script_to_constellation_chan()
|
||||
.send(ScriptMsg::RemoveBroadcastChannelRouter(
|
||||
*router_id,
|
||||
self.origin().immutable().clone(),
|
||||
));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::RemoveBroadcastChannelRouter(
|
||||
*router_id,
|
||||
self.origin().immutable().clone(),
|
||||
),
|
||||
);
|
||||
}
|
||||
*self.broadcast_channel_state.borrow_mut() = BroadcastChannelState::UnManaged;
|
||||
}
|
||||
|
@ -965,7 +966,7 @@ impl GlobalScope {
|
|||
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::EntanglePorts(port1, port2));
|
||||
.send(ScriptToConstellationMessage::EntanglePorts(port1, port2));
|
||||
}
|
||||
|
||||
/// Note that the entangled port of `port_id` has been removed in another global.
|
||||
|
@ -997,7 +998,7 @@ impl GlobalScope {
|
|||
port_impl.set_has_been_shipped();
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::MessagePortShipped(*port_id));
|
||||
.send(ScriptToConstellationMessage::MessagePortShipped(*port_id));
|
||||
port_impl
|
||||
} else {
|
||||
panic!("mark_port_as_transferred called on a global not managing any ports.");
|
||||
|
@ -1093,9 +1094,9 @@ impl GlobalScope {
|
|||
/// If we don't know about the port,
|
||||
/// send the message to the constellation for routing.
|
||||
fn re_route_port_task(&self, port_id: MessagePortId, task: PortMessageTask) {
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::RerouteMessagePort(port_id, task));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::RerouteMessagePort(port_id, task),
|
||||
);
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage>
|
||||
|
@ -1111,9 +1112,9 @@ impl GlobalScope {
|
|||
//
|
||||
// Note: for globals in the same script-thread,
|
||||
// we could skip the hop to the constellation.
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::ScheduleBroadcast(*router_id, msg));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::ScheduleBroadcast(*router_id, msg),
|
||||
);
|
||||
} else {
|
||||
panic!("Attemps to broadcast a message via global not managing any channels.");
|
||||
}
|
||||
|
@ -1286,12 +1287,9 @@ impl GlobalScope {
|
|||
}
|
||||
managed_port.pending = false;
|
||||
}
|
||||
let _ =
|
||||
self.script_to_constellation_chan()
|
||||
.send(ScriptMsg::CompleteMessagePortTransfer(
|
||||
*router_id,
|
||||
to_be_added,
|
||||
));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::CompleteMessagePortTransfer(*router_id, to_be_added),
|
||||
);
|
||||
} else {
|
||||
warn!("maybe_add_pending_ports called on a global not managing any ports.");
|
||||
}
|
||||
|
@ -1310,7 +1308,7 @@ impl GlobalScope {
|
|||
// and to forward this message to the script-process where the entangled is found.
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::RemoveMessagePort(*id));
|
||||
.send(ScriptToConstellationMessage::RemoveMessagePort(*id));
|
||||
Some(*id)
|
||||
} else {
|
||||
None
|
||||
|
@ -1340,7 +1338,7 @@ impl GlobalScope {
|
|||
channels.retain(|chan| !chan.closed());
|
||||
if channels.is_empty() {
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptMsg::RemoveBroadcastChannelNameInRouter(
|
||||
ScriptToConstellationMessage::RemoveBroadcastChannelNameInRouter(
|
||||
*router_id,
|
||||
name.to_string(),
|
||||
self.origin().immutable().clone(),
|
||||
|
@ -1382,19 +1380,19 @@ impl GlobalScope {
|
|||
);
|
||||
let router_id = BroadcastChannelRouterId::new();
|
||||
*current_state = BroadcastChannelState::Managed(router_id, HashMap::new());
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::NewBroadcastChannelRouter(
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::NewBroadcastChannelRouter(
|
||||
router_id,
|
||||
broadcast_control_sender,
|
||||
self.origin().immutable().clone(),
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if let BroadcastChannelState::Managed(router_id, channels) = &mut *current_state {
|
||||
let entry = channels.entry(dom_channel.Name()).or_insert_with(|| {
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptMsg::NewBroadcastChannelNameInRouter(
|
||||
ScriptToConstellationMessage::NewBroadcastChannelNameInRouter(
|
||||
*router_id,
|
||||
dom_channel.Name().to_string(),
|
||||
self.origin().immutable().clone(),
|
||||
|
@ -1434,12 +1432,9 @@ impl GlobalScope {
|
|||
);
|
||||
let router_id = MessagePortRouterId::new();
|
||||
*current_state = MessagePortState::Managed(router_id, HashMapTracedValues::new());
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::NewMessagePortRouter(
|
||||
router_id,
|
||||
port_control_sender,
|
||||
));
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::NewMessagePortRouter(router_id, port_control_sender),
|
||||
);
|
||||
}
|
||||
|
||||
if let MessagePortState::Managed(router_id, message_ports) = &mut *current_state {
|
||||
|
@ -1478,12 +1473,12 @@ impl GlobalScope {
|
|||
closed: false,
|
||||
},
|
||||
);
|
||||
let _ = self
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::NewMessagePort(
|
||||
let _ = self.script_to_constellation_chan().send(
|
||||
ScriptToConstellationMessage::NewMessagePort(
|
||||
*router_id,
|
||||
*dom_port.message_port_id(),
|
||||
));
|
||||
),
|
||||
);
|
||||
};
|
||||
} else {
|
||||
panic!("track_message_port should have first switched the state to managed.");
|
||||
|
@ -2229,10 +2224,10 @@ impl GlobalScope {
|
|||
}
|
||||
|
||||
pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) {
|
||||
self.send_to_constellation(ScriptMsg::ForwardToEmbedder(msg));
|
||||
self.send_to_constellation(ScriptToConstellationMessage::ForwardToEmbedder(msg));
|
||||
}
|
||||
|
||||
pub(crate) fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
pub(crate) fn send_to_constellation(&self, msg: ScriptToConstellationMessage) {
|
||||
self.script_to_constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue