diff options
author | Agustin Chiappe Berrini <jnieve@gmail.com> | 2018-09-08 17:01:27 -0400 |
---|---|---|
committer | Agustin Chiappe Berrini <jnieve@gmail.com> | 2018-09-08 17:01:27 -0400 |
commit | 5dd6e21c2e7e1c35a2a4a57812126e28a4b58599 (patch) | |
tree | 5c98fbf6599a4d3ea28f8f37f9c9d2cdd44b9610 /components/script/dom/globalscope.rs | |
parent | f7630dad87da33449ce05b5e7a9ef6f747e9531d (diff) | |
download | servo-5dd6e21c2e7e1c35a2a4a57812126e28a4b58599.tar.gz servo-5dd6e21c2e7e1c35a2a4a57812126e28a4b58599.zip |
Add Websocket task source
According to the doc: https://html.spec.whatwg.org/multipage/web-sockets.html#network
The task source for all tasks queued in the websocket section are the
websocket task source, so this commit also updates those references to
use the appropriate one.
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 596530058ec..b2429948874 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -59,6 +59,7 @@ use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; use task_source::remote_event::RemoteEventTaskSource; +use task_source::websocket::WebsocketTaskSource; use time::{Timespec, get_time}; use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle}; use timers::{OneshotTimers, TimerCallback}; @@ -430,6 +431,18 @@ impl GlobalScope { unreachable!(); } + /// `ScriptChan` to send messages to the websocket task source of + /// this global scope. + pub fn websocket_task_source(&self) -> WebsocketTaskSource { + if let Some(window) = self.downcast::<Window>() { + return window.websocket_task_source(); + } + if let Some(worker) = self.downcast::<WorkerGlobalScope>() { + return worker.websocket_task_source(); + } + unreachable!(); + } + /// Evaluate JS code on this global scope. pub fn evaluate_js_on_global_with_result( &self, code: &str, rval: MutableHandleValue) -> bool { |