mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -602,12 +602,12 @@ impl EventSourceMethods<crate::DomTypeHolder> for EventSource {
|
|||
listener.notify_fetch(message.unwrap());
|
||||
}),
|
||||
);
|
||||
let cancel_receiver = ev.canceller.borrow_mut().initialize();
|
||||
*ev.canceller.borrow_mut() = FetchCanceller::new(request.id);
|
||||
global
|
||||
.core_resource_thread()
|
||||
.send(CoreResourceMsg::Fetch(
|
||||
request,
|
||||
FetchChannels::ResponseMsg(action_sender, Some(cancel_receiver)),
|
||||
FetchChannels::ResponseMsg(action_sender),
|
||||
))
|
||||
.unwrap();
|
||||
// Step 13
|
||||
|
@ -681,7 +681,7 @@ impl EventSourceTimeoutCallback {
|
|||
.core_resource_thread()
|
||||
.send(CoreResourceMsg::Fetch(
|
||||
request,
|
||||
FetchChannels::ResponseMsg(self.action_sender, None),
|
||||
FetchChannels::ResponseMsg(self.action_sender),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue