diff options
-rw-r--r-- | components/profile/heartbeats.rs | 1 | ||||
-rw-r--r-- | components/profile/time.rs | 1 | ||||
-rw-r--r-- | components/profile_traits/time.rs | 1 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 37 | ||||
-rw-r--r-- | components/script/script_task.rs | 2 |
5 files changed, 6 insertions, 36 deletions
diff --git a/components/profile/heartbeats.rs b/components/profile/heartbeats.rs index 0101f62e25b..c87e9f542a8 100644 --- a/components/profile/heartbeats.rs +++ b/components/profile/heartbeats.rs @@ -52,7 +52,6 @@ pub fn init() { maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptSetViewport); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptWebSocketEvent); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptWorkerEvent); - maybe_create_heartbeat(&mut hbs, ProfilerCategory::ScriptXhrEvent); maybe_create_heartbeat(&mut hbs, ProfilerCategory::ApplicationHeartbeat); unsafe { HBS = Some(mem::transmute(Box::new(hbs))); diff --git a/components/profile/time.rs b/components/profile/time.rs index aa3fd79199a..0de493368af 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -102,7 +102,6 @@ impl Formattable for ProfilerCategory { ProfilerCategory::ScriptTimerEvent => "Script Timer Event", ProfilerCategory::ScriptWebSocketEvent => "Script Web Socket Event", ProfilerCategory::ScriptWorkerEvent => "Script Worker Event", - ProfilerCategory::ScriptXhrEvent => "Script Xhr Event", ProfilerCategory::ApplicationHeartbeat => "Application Heartbeat", }; format!("{}{}", padding, name) diff --git a/components/profile_traits/time.rs b/components/profile_traits/time.rs index 9fa31d69892..5ebfcc18e46 100644 --- a/components/profile_traits/time.rs +++ b/components/profile_traits/time.rs @@ -71,7 +71,6 @@ pub enum ProfilerCategory { ScriptTimerEvent, ScriptWebSocketEvent, ScriptWorkerEvent, - ScriptXhrEvent, ApplicationHeartbeat, } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 770bcaedf78..da5aab7710f 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -45,8 +45,7 @@ use net_traits::ControlMsg::Load; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata}; use net_traits::{LoadConsumer, LoadData, ResourceCORSData, ResourceTask}; use network_listener::{NetworkListener, PreInvoke}; -use script_task::ScriptTaskEventCategory::XhrEvent; -use script_task::{CommonScriptMsg, Runnable, ScriptChan, ScriptPort}; +use script_task::{ScriptChan, ScriptPort}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; @@ -139,8 +138,6 @@ pub struct XMLHttpRequest { global: GlobalField, timeout_cancel: DOMRefCell<Option<TimerHandle>>, fetch_time: Cell<i64>, - #[ignore_heap_size_of = "Cannot calculate Heap size"] - timeout_target: DOMRefCell<Option<Box<ScriptChan + Send>>>, generation_id: Cell<GenerationId>, response_status: Cell<Result<(), ()>>, } @@ -175,7 +172,6 @@ impl XMLHttpRequest { global: GlobalField::from_rooted(&global), timeout_cancel: DOMRefCell::new(None), fetch_time: Cell::new(0), - timeout_target: DOMRefCell::new(None), generation_id: Cell::new(GenerationId(0)), response_status: Cell::new(Ok(())), } @@ -919,7 +915,6 @@ impl XMLHttpRequest { fn terminate_ongoing_fetch(&self) { let GenerationId(prev_id) = self.generation_id.get(); self.generation_id.set(GenerationId(prev_id + 1)); - *self.timeout_target.borrow_mut() = None; self.response_status.set(Ok(())); } @@ -958,25 +953,8 @@ impl XMLHttpRequest { self.dispatch_progress_event(false, type_, len, total); } fn set_timeout(&self, duration_ms: u32) { - struct XHRTimeout { - xhr: TrustedXHRAddress, - gen_id: GenerationId, - } - - impl Runnable for XHRTimeout { - fn handler(self: Box<XHRTimeout>) { - let this = *self; - let xhr = this.xhr.root(); - if xhr.ready_state.get() != XMLHttpRequestState::Done { - xhr.process_partial_response(XHRProgress::Errored(this.gen_id, Error::Timeout)); - } - } - } - #[derive(JSTraceable, HeapSizeOf)] struct ScheduledXHRTimeout { - #[ignore_heap_size_of = "Cannot calculate Heap size"] - target: Box<ScriptChan + Send>, #[ignore_heap_size_of = "Because it is non-owning"] xhr: Trusted<XMLHttpRequest>, generation_id: GenerationId, @@ -984,16 +962,15 @@ impl XMLHttpRequest { impl ScheduledCallback for ScheduledXHRTimeout { fn invoke(self: Box<Self>) { - let s = *self; - s.target.send(CommonScriptMsg::RunnableMsg(XhrEvent, box XHRTimeout { - xhr: s.xhr, - gen_id: s.generation_id, - })).unwrap(); + let this = *self; + let xhr = this.xhr.root(); + if xhr.ready_state.get() != XMLHttpRequestState::Done { + xhr.process_partial_response(XHRProgress::Errored(this.generation_id, Error::Timeout)); + } } fn box_clone(&self) -> Box<ScheduledCallback> { box ScheduledXHRTimeout { - target: self.target.clone(), xhr: self.xhr.clone(), generation_id: self.generation_id, } @@ -1004,7 +981,6 @@ impl XMLHttpRequest { // This will cancel all previous timeouts let global = self.global.root(); let callback = ScheduledXHRTimeout { - target: (*self.timeout_target.borrow().as_ref().unwrap()).clone(), xhr: Trusted::new(global.r().get_cx(), self, global.r().script_chan()), generation_id: self.generation_id.get(), }; @@ -1104,7 +1080,6 @@ impl XMLHttpRequest { } else { (global.script_chan(), None) }; - *self.timeout_target.borrow_mut() = Some(script_chan.clone()); let resource_task = global.resource_task(); if let Some(req) = cors_request { diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 28e194b2a4a..99312a61bd6 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -236,7 +236,6 @@ pub enum ScriptTaskEventCategory { SetViewport, WebSocketEvent, WorkerEvent, - XhrEvent, } /// Messages used to control the script event loop @@ -954,7 +953,6 @@ impl ScriptTask { ScriptTaskEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent, ScriptTaskEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent, ScriptTaskEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent, - ScriptTaskEventCategory::XhrEvent => ProfilerCategory::ScriptXhrEvent, }; profile(profiler_cat, None, self.time_profiler_chan.clone(), f) } else { |