mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
@ -128,7 +128,7 @@ impl FileManager {
|
|||
pub fn fetch_file(
|
||||
&self,
|
||||
done_sender: &mut TokioSender<Data>,
|
||||
cancellation_listener: Arc<Mutex<CancellationListener>>,
|
||||
cancellation_listener: Arc<CancellationListener>,
|
||||
id: Uuid,
|
||||
file_token: &FileTokenCheck,
|
||||
origin: FileOrigin,
|
||||
|
@ -211,7 +211,7 @@ impl FileManager {
|
|||
done_sender: &mut TokioSender<Data>,
|
||||
mut reader: BufReader<File>,
|
||||
res_body: ServoArc<Mutex<ResponseBody>>,
|
||||
cancellation_listener: Arc<Mutex<CancellationListener>>,
|
||||
cancellation_listener: Arc<CancellationListener>,
|
||||
range: RelativePos,
|
||||
) {
|
||||
let done_sender = done_sender.clone();
|
||||
|
@ -220,7 +220,7 @@ impl FileManager {
|
|||
.map(|pool| {
|
||||
pool.spawn(move || {
|
||||
loop {
|
||||
if cancellation_listener.lock().unwrap().cancelled() {
|
||||
if cancellation_listener.cancelled() {
|
||||
*res_body.lock().unwrap() = ResponseBody::Done(vec![]);
|
||||
let _ = done_sender.send(Data::Cancelled);
|
||||
return;
|
||||
|
@ -282,7 +282,7 @@ impl FileManager {
|
|||
fn fetch_blob_buf(
|
||||
&self,
|
||||
done_sender: &mut TokioSender<Data>,
|
||||
cancellation_listener: Arc<Mutex<CancellationListener>>,
|
||||
cancellation_listener: Arc<CancellationListener>,
|
||||
id: &Uuid,
|
||||
file_token: &FileTokenCheck,
|
||||
origin_in: &FileOrigin,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue