mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
net: Use RequestId
to cancel fetches instead of creating an IPC channel (#34883)
Instead of creating an IPC channel for every fetch, allow cancelling fetches based on the `RequestId` of the original request. This requires that `RequestId`s be UUIDs so that they are unique between processes that might communicating with the resource process. In addition, the resource process loop now keeps a `HashMap` or `Weak` handles to cancellers and cleans them up. This allows for creating mutiple `FetchCanceller`s in `script` for a single fetch request, allowing integration of the media and video elements to integrate with the `Document` canceller list -- meaning these fetches also get cancelled when the `Document` unloads. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
e2be55b873
commit
748954d610
23 changed files with 179 additions and 226 deletions
|
@ -6,7 +6,6 @@
|
|||
//!
|
||||
//! <https://html.spec.whatwg.org/multipage/#the-end>
|
||||
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::request::RequestBuilder;
|
||||
use net_traits::{fetch_async, BoxedFetchCallback, ResourceThreads};
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -121,7 +120,7 @@ impl DocumentLoader {
|
|||
callback: BoxedFetchCallback,
|
||||
) {
|
||||
self.add_blocking_load(load);
|
||||
self.fetch_async_background(request, callback, None);
|
||||
self.fetch_async_background(request, callback);
|
||||
}
|
||||
|
||||
/// Initiate a new fetch that does not block the document load event.
|
||||
|
@ -129,22 +128,9 @@ impl DocumentLoader {
|
|||
&mut self,
|
||||
request: RequestBuilder,
|
||||
callback: BoxedFetchCallback,
|
||||
cancel_override: Option<ipc::IpcReceiver<()>>,
|
||||
) {
|
||||
let canceller = cancel_override.unwrap_or_else(|| {
|
||||
let mut canceller = FetchCanceller::new();
|
||||
let cancel_receiver = canceller.initialize();
|
||||
self.cancellers.push(canceller);
|
||||
cancel_receiver
|
||||
});
|
||||
|
||||
fetch_async(
|
||||
&self.resource_threads.core_thread,
|
||||
request,
|
||||
None, /* response_init */
|
||||
Some(canceller),
|
||||
callback,
|
||||
);
|
||||
self.cancellers.push(FetchCanceller::new(request.id));
|
||||
fetch_async(&self.resource_threads.core_thread, request, None, callback);
|
||||
}
|
||||
|
||||
/// Mark an in-progress network request complete.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue