script: add TaskSource argument to route_promise (#36831)

Added task_source argument to route_promise, enabling callers to pick
the correct TaskSource.

Testing: No testing required, straightforward refactor
Fixes: #36825

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24 2025-05-04 19:05:27 +02:00 committed by GitHub
parent 1e8896800a
commit 7e2d2ed0ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 46 additions and 15 deletions

View file

@ -10,9 +10,10 @@ use serde::Serialize;
use serde::de::DeserializeOwned;
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
use crate::dom::bindings::reflector::{DomGlobal, DomObject};
use crate::dom::bindings::reflector::DomObject;
use crate::dom::promise::Promise;
use crate::script_runtime::CanGc;
use crate::task_source::TaskSource;
pub(crate) trait RoutedPromiseListener<R: Serialize + DeserializeOwned + Send> {
fn handle_response(&self, response: R, promise: &Rc<Promise>, can_gc: CanGc);
@ -44,13 +45,10 @@ pub(crate) fn route_promise<
>(
promise: &Rc<Promise>,
receiver: &T,
task_source: TaskSource,
) -> IpcSender<R> {
let (action_sender, action_receiver) = ipc::channel().unwrap();
let task_source = receiver
.global()
.task_manager()
.dom_manipulation_task_source()
.to_sendable();
let task_source = task_source.to_sendable();
let mut trusted: Option<TrustedPromise> = Some(TrustedPromise::new(promise.clone()));
let trusted_receiver = Trusted::new(receiver);
ROUTER.add_typed_route(