mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Use FetchCanceller for document loads
This commit is contained in:
parent
78c8b4232f
commit
3900f5e616
11 changed files with 51 additions and 24 deletions
|
@ -62,6 +62,7 @@ use dom::worker::TrustedWorkerAddress;
|
|||
use dom::worklet::WorkletThreadPool;
|
||||
use dom::workletglobalscope::WorkletGlobalScopeInit;
|
||||
use euclid::{Point2D, Vector2D, Rect};
|
||||
use fetch::FetchCanceller;
|
||||
use hyper::header::{ContentType, HttpDate, Headers, LastModified};
|
||||
use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;
|
||||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
|
@ -170,6 +171,8 @@ struct InProgressLoad {
|
|||
navigation_start: u64,
|
||||
/// High res timestamp reporting the time when the browser started this load.
|
||||
navigation_start_precise: u64,
|
||||
/// For cancelling the fetch
|
||||
canceller: FetchCanceller,
|
||||
}
|
||||
|
||||
impl InProgressLoad {
|
||||
|
@ -198,6 +201,7 @@ impl InProgressLoad {
|
|||
origin: origin,
|
||||
navigation_start: (current_time.sec * 1000 + current_time.nsec as i64 / 1000000) as u64,
|
||||
navigation_start_precise: navigation_start_precise,
|
||||
canceller: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2215,7 +2219,8 @@ impl ScriptThread {
|
|||
DocumentSource::FromParser,
|
||||
loader,
|
||||
referrer,
|
||||
referrer_policy);
|
||||
referrer_policy,
|
||||
incomplete.canceller);
|
||||
document.set_ready_state(DocumentReadyState::Loading);
|
||||
|
||||
self.documents.borrow_mut().insert(incomplete.pipeline_id, &*document);
|
||||
|
@ -2536,7 +2541,7 @@ impl ScriptThread {
|
|||
|
||||
/// Instructs the constellation to fetch the document that will be loaded. Stores the InProgressLoad
|
||||
/// argument until a notification is received that the fetch is complete.
|
||||
fn pre_page_load(&self, incomplete: InProgressLoad, load_data: LoadData) {
|
||||
fn pre_page_load(&self, mut incomplete: InProgressLoad, load_data: LoadData) {
|
||||
let id = incomplete.pipeline_id.clone();
|
||||
let req_init = RequestInit {
|
||||
url: load_data.url.clone(),
|
||||
|
@ -2557,7 +2562,9 @@ impl ScriptThread {
|
|||
let context = ParserContext::new(id, load_data.url);
|
||||
self.incomplete_parser_contexts.borrow_mut().push((id, context));
|
||||
|
||||
self.script_sender.send((id, ScriptMsg::InitiateNavigateRequest(req_init))).unwrap();
|
||||
let cancel_chan = incomplete.canceller.initialize();
|
||||
|
||||
self.script_sender.send((id, ScriptMsg::InitiateNavigateRequest(req_init, cancel_chan))).unwrap();
|
||||
self.incomplete_loads.borrow_mut().push(incomplete);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue