aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/websocket.rs
diff options
context:
space:
mode:
authorChad Kimes <ckimes89@gmail.com>2016-01-10 22:24:33 -0500
committerChad Kimes <ckimes89@gmail.com>2016-01-10 22:24:33 -0500
commitfbe91076147c62eb19c769c48b81a5e06e671f0b (patch)
tree2f955582755bcbc1c6af189934695cda9e6185ad /components/script/dom/websocket.rs
parent25814021ea014cbe432457e83518c176dce315a4 (diff)
downloadservo-fbe91076147c62eb19c769c48b81a5e06e671f0b.tar.gz
servo-fbe91076147c62eb19c769c48b81a5e06e671f0b.zip
Remove global field from WebSocket
Diffstat (limited to 'components/script/dom/websocket.rs')
-rw-r--r--components/script/dom/websocket.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs
index 95ade2e61d7..141b2c680f2 100644
--- a/components/script/dom/websocket.rs
+++ b/components/script/dom/websocket.rs
@@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::WebSocketBinding;
use dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMethods};
use dom::bindings::conversions::{ToJSValConvertible};
use dom::bindings::error::{Error, Fallible};
-use dom::bindings::global::{GlobalField, GlobalRef};
+use dom::bindings::global::{GlobalRef, global_root_from_reflector};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::refcounted::Trusted;
@@ -136,7 +136,6 @@ mod close_code {
pub struct WebSocket {
eventtarget: EventTarget,
url: Url,
- global: GlobalField,
ready_state: Cell<WebSocketRequestState>,
buffered_amount: Cell<u64>,
clearing_buffer: Cell<bool>, //Flag to tell if there is a running thread to clear buffered_amount
@@ -152,11 +151,10 @@ pub struct WebSocket {
}
impl WebSocket {
- fn new_inherited(global: GlobalRef, url: Url) -> WebSocket {
+ fn new_inherited(url: Url) -> WebSocket {
WebSocket {
eventtarget: EventTarget::new_inherited(),
url: url,
- global: GlobalField::from_rooted(&global),
ready_state: Cell::new(WebSocketRequestState::Connecting),
buffered_amount: Cell::new(0),
clearing_buffer: Cell::new(false),
@@ -169,11 +167,10 @@ impl WebSocket {
binary_type: Cell::new(BinaryType::Blob),
protocol: DOMRefCell::new("".to_owned()),
}
-
}
fn new(global: GlobalRef, url: Url) -> Root<WebSocket> {
- reflect_dom_object(box WebSocket::new_inherited(global, url),
+ reflect_dom_object(box WebSocket::new_inherited(url),
global, WebSocketBinding::Wrap)
}
@@ -295,7 +292,7 @@ impl WebSocket {
WebSocketRequestState::Closing | WebSocketRequestState::Closed => true,
};
- let global = self.global.root();
+ let global = global_root_from_reflector(self);
let chan = global.r().networking_thread_source();
let address = Trusted::new(self, chan.clone());
@@ -463,7 +460,7 @@ struct ConnectionEstablishedTask {
impl Runnable for ConnectionEstablishedTask {
fn handler(self: Box<Self>) {
let ws = self.addr.root();
- let global = ws.global.root();
+ let global = global_root_from_reflector(ws.r());
// Step 1: Protocols.
if !self.protocols.is_empty() && self.headers.get::<WebSocketProtocol>().is_none() {
@@ -522,7 +519,7 @@ impl Runnable for CloseTask {
fn handler(self: Box<Self>) {
let ws = self.addr.root();
let ws = ws.r();
- let global = ws.global.root();
+ let global = global_root_from_reflector(ws);
ws.ready_state.set(WebSocketRequestState::Closed);
//If failed or full, fire error event
if ws.failed.get() || ws.full.get() {
@@ -568,7 +565,7 @@ impl Runnable for MessageReceivedTask {
}
// Step 2-5.
- let global = ws.global.root();
+ let global = global_root_from_reflector(ws.r());
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
unsafe {
let cx = global.r().get_cx();