net: Use callbacks instead of IPC channels in the ImageCache API (#40453)

Previously, the `ImageCache` would inform consumers of changes to image
availability by messaging an IPC channel. This isn't great, because it
requires serialization and deserialization. Nowadays, `ImageCache`s are
always owned by the same `Global` that uses them. This change replaces
the IPC channel with callback that implements `Send`.

For the case of normal HTML document images, the results are still sent
over the pre-existing Crossbeam channel that was connected via an IPC
route. A followup change might eliminate that channel entirely.

Testing: This should not change observable behavior so is covered by
existing tests.
Fixes: #24338.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson
2025-11-06 13:52:40 +01:00
committed by GitHub
parent 67d15c706f
commit bdcae320fd
9 changed files with 77 additions and 99 deletions

View File

@@ -896,13 +896,6 @@ impl ScriptThread {
);
let (image_cache_sender, image_cache_receiver) = unbounded();
let (ipc_image_cache_sender, ipc_image_cache_receiver) = ipc::channel().unwrap();
ROUTER.add_typed_route(
ipc_image_cache_receiver,
Box::new(move |message| {
let _ = image_cache_sender.send(message.unwrap());
}),
);
let receivers = ScriptThreadReceivers {
constellation_receiver,
@@ -921,7 +914,7 @@ impl ScriptThread {
constellation_sender: state.constellation_sender,
pipeline_to_constellation_sender: state.pipeline_to_constellation_sender.sender.clone(),
pipeline_to_embedder_sender: state.pipeline_to_embedder_sender.clone(),
image_cache_sender: ipc_image_cache_sender,
image_cache_sender,
time_profiler_sender: state.time_profiler_sender,
memory_profiler_sender: state.memory_profiler_sender,
devtools_server_sender,