aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2017-11-21 16:43:50 -0800
committerManish Goregaokar <manishsmail@gmail.com>2017-11-22 14:06:27 -0800
commit3900f5e616397ac7f9fae2875a6b58557796ef90 (patch)
tree98c466e172dc2e61e8f6e207849175c303baead0 /components/script/script_thread.rs
parent78c8b4232fd10d2180d138f14260e322ac8f0826 (diff)
downloadservo-3900f5e616397ac7f9fae2875a6b58557796ef90.tar.gz
servo-3900f5e616397ac7f9fae2875a6b58557796ef90.zip
Use FetchCanceller for document loads
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d969a46fecc..efae319df92 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -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);
}