From 671627e97e20ae4baf728ae6dda61ef6f857c193 Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Thu, 5 Jul 2018 12:33:09 +0800 Subject: introduce "per task source" ignoring of tasks --- components/script/dom/websocket.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'components/script/dom/websocket.rs') diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 031741db0df..14ff325f56d 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -39,7 +39,7 @@ use std::cell::Cell; use std::ptr; use std::thread; use task::{TaskOnce, TaskCanceller}; -use task_source::TaskSource; +use task_source::{TaskSource, TaskSourceName}; use task_source::networking::NetworkingTaskSource; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] @@ -199,8 +199,11 @@ impl WebSocket { }; let _ = global.core_resource_thread().send(CoreResourceMsg::Fetch(request, channels)); + // TODO: use a dedicated task source, + // https://html.spec.whatwg.org/multipage/#websocket-task-source + // When making the switch, also update the task_canceller call. let task_source = global.networking_task_source(); - let canceller = global.task_canceller(); + let canceller = global.task_canceller(TaskSourceName::Networking); thread::spawn(move || { while let Ok(event) = dom_event_receiver.recv() { match event { @@ -391,8 +394,13 @@ impl WebSocketMethods for WebSocket { self.ready_state.set(WebSocketRequestState::Closing); let address = Trusted::new(self); + // TODO: use a dedicated task source, + // https://html.spec.whatwg.org/multipage/#websocket-task-source + // When making the switch, also update the task_canceller call. let task_source = self.global().networking_task_source(); - fail_the_websocket_connection(address, &task_source, &self.global().task_canceller()); + fail_the_websocket_connection(address, + &task_source, + &self.global().task_canceller(TaskSourceName::Networking)); } WebSocketRequestState::Open => { self.ready_state.set(WebSocketRequestState::Closing); -- cgit v1.2.3