devtools: improve ID Naming for better readability and context (#35942)

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
atbrakhi 2025-03-13 08:36:54 +01:00 committed by GitHub
parent 7594dc6991
commit eb2ca42824
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 60 additions and 60 deletions

View file

@ -173,9 +173,9 @@ impl Actor for BrowsingContextActor {
impl BrowsingContextActor {
pub(crate) fn new(
console: String,
id: BrowsingContextId,
browsing_context_id: BrowsingContextId,
page_info: DevtoolsPageInfo,
pipeline: PipelineId,
pipeline_id: PipelineId,
script_sender: IpcSender<DevtoolScriptControlMsg>,
actors: &mut ActorRegistry,
) -> BrowsingContextActor {
@ -224,8 +224,8 @@ impl BrowsingContextActor {
script_chan: script_sender,
title: RefCell::new(title),
url: RefCell::new(url.into_string()),
active_pipeline: Cell::new(pipeline),
browsing_context_id: id,
active_pipeline: Cell::new(pipeline_id),
browsing_context_id,
accessibility: accessibility.name(),
console,
css_properties: css_properties.name(),
@ -308,8 +308,8 @@ impl BrowsingContextActor {
}
}
pub(crate) fn title_changed(&self, pipeline: PipelineId, title: String) {
if pipeline != self.active_pipeline.get() {
pub(crate) fn title_changed(&self, pipeline_id: PipelineId, title: String) {
if pipeline_id != self.active_pipeline.get() {
return;
}
*self.title.borrow_mut() = title;

View file

@ -155,7 +155,7 @@ impl ConsoleActor {
.active_pipeline
.get(),
),
Root::DedicatedWorker(w) => UniqueId::Worker(registry.find::<WorkerActor>(w).id),
Root::DedicatedWorker(w) => UniqueId::Worker(registry.find::<WorkerActor>(w).worker_id),
}
}

View file

@ -16,7 +16,7 @@ use crate::actors::timeline::HighResolutionStamp;
pub struct FramerateActor {
name: String,
pipeline: PipelineId,
pipeline_id: PipelineId,
script_sender: IpcSender<DevtoolScriptControlMsg>,
is_recording: bool,
ticks: Vec<HighResolutionStamp>,
@ -49,7 +49,7 @@ impl FramerateActor {
let actor_name = registry.new_name("framerate");
let mut actor = FramerateActor {
name: actor_name.clone(),
pipeline: pipeline_id,
pipeline_id,
script_sender,
is_recording: false,
ticks: Vec::new(),
@ -64,7 +64,7 @@ impl FramerateActor {
self.ticks.push(HighResolutionStamp::wrap(tick));
if self.is_recording {
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name());
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline_id, self.name());
self.script_sender.send(msg).unwrap();
}
}
@ -80,7 +80,7 @@ impl FramerateActor {
self.is_recording = true;
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name());
let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline_id, self.name());
self.script_sender.send(msg).unwrap();
}

View file

@ -30,7 +30,7 @@ pub struct TimelineActor {
name: String,
script_sender: IpcSender<DevtoolScriptControlMsg>,
marker_types: Vec<TimelineMarkerType>,
pipeline: PipelineId,
pipeline_id: PipelineId,
is_recording: Arc<Mutex<bool>>,
stream: RefCell<Option<TcpStream>>,
@ -132,14 +132,14 @@ static DEFAULT_TIMELINE_DATA_PULL_TIMEOUT: u64 = 200; //ms
impl TimelineActor {
pub fn new(
name: String,
pipeline: PipelineId,
pipeline_id: PipelineId,
script_sender: IpcSender<DevtoolScriptControlMsg>,
) -> TimelineActor {
let marker_types = vec![TimelineMarkerType::Reflow, TimelineMarkerType::DOMEvent];
TimelineActor {
name,
pipeline,
pipeline_id,
marker_types,
script_sender,
is_recording: Arc::new(Mutex::new(false)),
@ -204,7 +204,7 @@ impl Actor for TimelineActor {
let (tx, rx) = ipc::channel::<Option<TimelineMarker>>().unwrap();
self.script_sender
.send(SetTimelineMarkers(
self.pipeline,
self.pipeline_id,
self.marker_types.clone(),
tx,
))
@ -225,7 +225,7 @@ impl Actor for TimelineActor {
if let Some(true) = with_ticks.as_bool() {
let framerate_actor = Some(FramerateActor::create(
registry,
self.pipeline,
self.pipeline_id,
self.script_sender.clone(),
));
*self.framerate_actor.borrow_mut() = framerate_actor;
@ -266,7 +266,7 @@ impl Actor for TimelineActor {
let _ = stream.write_json_packet(&msg);
self.script_sender
.send(DropTimelineMarkers(
self.pipeline,
self.pipeline_id,
self.marker_types.clone(),
))
.unwrap();

View file

@ -30,7 +30,7 @@ pub(crate) struct WorkerActor {
pub name: String,
pub console: String,
pub thread: String,
pub id: WorkerId,
pub worker_id: WorkerId,
pub url: ServoUrl,
pub type_: WorkerType,
pub script_chan: IpcSender<DevtoolScriptControlMsg>,
@ -43,7 +43,7 @@ impl WorkerActor {
actor: self.name.clone(),
console_actor: self.console.clone(),
thread_actor: self.thread.clone(),
id: self.id.0.to_string(),
worker_id: self.worker_id.0.to_string(),
url: self.url.to_string(),
traits: WorkerTraits {
is_parent_intercept_enabled: false,
@ -63,7 +63,7 @@ impl Actor for WorkerActor {
msg_type: &str,
_msg: &Map<String, Value>,
stream: &mut TcpStream,
id: StreamId,
stream_id: StreamId,
) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"attach" => {
@ -77,7 +77,7 @@ impl Actor for WorkerActor {
}
self.streams
.borrow_mut()
.insert(id, stream.try_clone().unwrap());
.insert(stream_id, stream.try_clone().unwrap());
// FIXME: fix messages to not require forging a pipeline for worker messages
self.script_chan
.send(WantsLiveNotifications(TEST_PIPELINE_ID, true))
@ -102,7 +102,7 @@ impl Actor for WorkerActor {
type_: "detached".to_string(),
};
let _ = stream.write_json_packet(&msg);
self.cleanup(id);
self.cleanup(stream_id);
ActorMessageStatus::Processed
},
@ -110,8 +110,8 @@ impl Actor for WorkerActor {
})
}
fn cleanup(&self, id: StreamId) {
self.streams.borrow_mut().remove(&id);
fn cleanup(&self, stream_id: StreamId) {
self.streams.borrow_mut().remove(&stream_id);
if self.streams.borrow().is_empty() {
self.script_chan
.send(WantsLiveNotifications(TEST_PIPELINE_ID, false))
@ -157,7 +157,7 @@ pub(crate) struct WorkerMsg {
actor: String,
console_actor: String,
thread_actor: String,
id: String,
worker_id: String,
url: String,
traits: WorkerTraits,
#[serde(rename = "type")]