diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-07-15 15:47:13 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-07-22 20:28:17 +0200 |
commit | 91849cb603a43ecdc403d059788ae79fb28e1f4a (patch) | |
tree | 53cdd98865bb4736fc7173e8cc733c42d51bff60 /components/script/dom/websocket.rs | |
parent | 78df6e8d3e59d14dfecdad81f1276f34de49cd61 (diff) | |
download | servo-91849cb603a43ecdc403d059788ae79fb28e1f4a.tar.gz servo-91849cb603a43ecdc403d059788ae79fb28e1f4a.zip |
Set the WebSocket's Sender from the ConnectionEstablishedTask.
This needs to happen off a task because we won't be able to access the
WebSocket object directly once this code moves to a background thread.
There is no behaviour change, because we make sure that self.ready_state is
not Connecting in Send().
Diffstat (limited to 'components/script/dom/websocket.rs')
-rw-r--r-- | components/script/dom/websocket.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index aeb13ac4f95..2e415e5d73d 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -147,14 +147,13 @@ impl WebSocket { } }; - *ws.r().sender.borrow_mut() = Some(temp_sender); - //Create everything necessary for starting the open asynchronous task, then begin the task. let global_root = ws.r().global.root(); let addr: Trusted<WebSocket> = Trusted::new(global_root.r().get_cx(), ws.r(), global_root.r().script_chan().clone()); let open_task = box ConnectionEstablishedTask { addr: addr, + sender: temp_sender, }; global_root.r().script_chan().send(ScriptMsg::RunnableMsg(open_task)).unwrap(); //TODO: Spawn thread here for receive loop @@ -276,12 +275,15 @@ impl<'a> WebSocketMethods for &'a WebSocket { /// Task queued when *the WebSocket connection is established*. struct ConnectionEstablishedTask { addr: Trusted<WebSocket>, + sender: Sender<WebSocketStream>, } impl Runnable for ConnectionEstablishedTask { fn handler(self: Box<Self>) { let ws = self.addr.root(); + *ws.r().sender.borrow_mut() = Some(self.sender); + // Step 1: Protocols. // Step 2. |