diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-11 12:49:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-11 11:49:22 +0000 |
commit | 748954d610e5357b19506d0f9390bc769dd32213 (patch) | |
tree | 2e035c4dceefe825353cf6b4545d7d3387c98672 /components/net/tests | |
parent | e2be55b873e7bd28c7bd8f92688e7f2035611326 (diff) | |
download | servo-748954d610e5357b19506d0f9390bc769dd32213.tar.gz servo-748954d610e5357b19506d0f9390bc769dd32213.zip |
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>
Diffstat (limited to 'components/net/tests')
-rw-r--r-- | components/net/tests/fetch.rs | 8 | ||||
-rw-r--r-- | components/net/tests/main.rs | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs index eef8ba89a66..30460a55d38 100644 --- a/components/net/tests/fetch.rs +++ b/components/net/tests/fetch.rs @@ -26,7 +26,7 @@ use hyper::body::{Bytes, Incoming}; use hyper::{Request as HyperRequest, Response as HyperResponse}; use mime::{self, Mime}; use net::fetch::cors_cache::CorsCache; -use net::fetch::methods::{self, CancellationListener, FetchContext}; +use net::fetch::methods::{self, FetchContext}; use net::filemanager_thread::FileManager; use net::hsts::HstsEntry; use net::protocols::ProtocolRegistry; @@ -702,7 +702,7 @@ fn test_fetch_with_hsts() { Weak::new(), ))), file_token: FileTokenCheck::NotRequired, - cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), + cancellation_listener: Arc::new(Default::default()), timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), @@ -759,7 +759,7 @@ fn test_load_adds_host_to_hsts_list_when_url_is_https() { Weak::new(), ))), file_token: FileTokenCheck::NotRequired, - cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), + cancellation_listener: Arc::new(Default::default()), timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), @@ -818,7 +818,7 @@ fn test_fetch_self_signed() { Weak::new(), ))), file_token: FileTokenCheck::NotRequired, - cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), + cancellation_listener: Arc::new(Default::default()), timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index 934f0e2102e..e8c576682fe 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -39,7 +39,7 @@ use hyper::{Request as HyperRequest, Response as HyperResponse}; use hyper_util::rt::tokio::TokioIo; use net::connector::{create_http_client, create_tls_config}; use net::fetch::cors_cache::CorsCache; -use net::fetch::methods::{self, CancellationListener, FetchContext}; +use net::fetch::methods::{self, FetchContext}; use net::filemanager_thread::FileManager; use net::protocols::ProtocolRegistry; use net::resource_thread::CoreResourceThreadPool; @@ -183,7 +183,7 @@ fn new_fetch_context( pool_handle.unwrap_or_else(|| Weak::new()), ))), file_token: FileTokenCheck::NotRequired, - cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), + cancellation_listener: Arc::new(Default::default()), timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), |