diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-09-10 09:11:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-10 09:11:44 -0400 |
commit | 78ad1df0b008c782cc496bed45c5898c2ba545ac (patch) | |
tree | 55e338e5c074039ec9b2c63b883b34af50e4d833 /components/script/dom/websocket.rs | |
parent | 0341b87b8b7db066a14503ac97aac93ea3c68699 (diff) | |
parent | 5dd6e21c2e7e1c35a2a4a57812126e28a4b58599 (diff) | |
download | servo-78ad1df0b008c782cc496bed45c5898c2ba545ac.tar.gz servo-78ad1df0b008c782cc496bed45c5898c2ba545ac.zip |
Auto merge of #21645 - AgustinCB:add-websocket-task-queue, r=jdm
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.
Also, while working on this, I made a typo here: https://github.com/AgustinCB/servo/blob/5dd6e21c2e7e1c35a2a4a57812126e28a4b58599/components/script/dom/window.rs#L191
Setting the name incorrectly. The error, however, was this:
```bash
error[E0412]: cannot find type `WebsocketEventTaskSource` in this scope
--> components/script/dom/window.rs:171:1
|
171 | #[dom_struct]
| ^^^^^^^^^^^^^ did you mean `WebsocketTaskSource`?
```
Which isn't useful at all. Not sure if it's a rustc problem or something related with htis code base, but I thought it was worth mentioning.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21590
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they don't include new behavior and existing tests should cover this code.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21645)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/websocket.rs')
-rw-r--r-- | components/script/dom/websocket.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 0a319bdc92e..ac0f14ad436 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -39,8 +39,8 @@ use std::cell::Cell; use std::ptr; use std::thread; use task::{TaskOnce, TaskCanceller}; -use task_source::{TaskSource, TaskSourceName}; -use task_source::networking::NetworkingTaskSource; +use task_source::TaskSource; +use task_source::websocket::WebsocketTaskSource; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] enum WebSocketRequestState { @@ -70,7 +70,7 @@ mod close_code { pub fn close_the_websocket_connection( address: Trusted<WebSocket>, - task_source: &NetworkingTaskSource, + task_source: &WebsocketTaskSource, canceller: &TaskCanceller, code: Option<u16>, reason: String, @@ -86,7 +86,7 @@ pub fn close_the_websocket_connection( pub fn fail_the_websocket_connection( address: Trusted<WebSocket>, - task_source: &NetworkingTaskSource, + task_source: &WebsocketTaskSource, canceller: &TaskCanceller, ) { let close_task = CloseTask { @@ -199,11 +199,8 @@ 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(TaskSourceName::Networking); + let task_source = global.websocket_task_source(); + let canceller = global.task_canceller(WebsocketTaskSource::NAME); thread::spawn(move || { while let Ok(event) = dom_event_receiver.recv() { match event { @@ -273,7 +270,7 @@ impl WebSocket { WebSocketEvent, task, Some(pipeline_id), - TaskSourceName::Networking, + WebsocketTaskSource::NAME, )) .unwrap(); } @@ -407,10 +404,10 @@ impl WebSocketMethods for WebSocket { // 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(); + let task_source = self.global().websocket_task_source(); fail_the_websocket_connection(address, &task_source, - &self.global().task_canceller(TaskSourceName::Networking)); + &self.global().task_canceller(WebsocketTaskSource::NAME)); } WebSocketRequestState::Open => { self.ready_state.set(WebSocketRequestState::Closing); |