From 71b4143d32398623f584e93d9fdc2e862344301f Mon Sep 17 00:00:00 2001 From: Tetsuharu OHZEKI Date: Tue, 21 Oct 2014 02:17:32 +0900 Subject: [PATCH] Use DOMRefCell for XMLHttpRequest. --- components/script/dom/xmlhttprequest.rs | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 02f7070ad3c..628eeb2e074 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::XMLHttpRequestBinding; use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestMethods; @@ -50,7 +51,7 @@ use servo_util::str::DOMString; use servo_util::task::spawn_named; use std::ascii::StrAsciiExt; -use std::cell::{Cell, RefCell}; +use std::cell::Cell; use std::comm::{Sender, Receiver, channel}; use std::default::Default; use std::io::{BufReader, MemWriter, Timer}; @@ -111,16 +112,16 @@ pub struct XMLHttpRequest { upload: JS, response_url: DOMString, status: Cell, - status_text: RefCell, - response: RefCell, + status_text: DOMRefCell, + response: DOMRefCell, response_type: Cell, response_xml: MutNullableJS, - response_headers: RefCell, + response_headers: DOMRefCell, // Associated concepts - request_method: RefCell, - request_url: RefCell>, - request_headers: RefCell, + request_method: DOMRefCell, + request_url: DOMRefCell>, + request_headers: DOMRefCell, request_body_len: Cell, sync: Cell, upload_complete: Cell, @@ -129,10 +130,10 @@ pub struct XMLHttpRequest { global: GlobalField, pinned_count: Cell, - timer: RefCell, + timer: DOMRefCell, fetch_time: Cell, timeout_pinned: Cell, - terminate_sender: RefCell>>, + terminate_sender: DOMRefCell>>, } impl XMLHttpRequest { @@ -145,15 +146,15 @@ impl XMLHttpRequest { upload: JS::from_rooted(XMLHttpRequestUpload::new(global)), response_url: "".to_string(), status: Cell::new(0), - status_text: RefCell::new(ByteString::new(vec!())), - response: RefCell::new(ByteString::new(vec!())), + status_text: DOMRefCell::new(ByteString::new(vec!())), + response: DOMRefCell::new(ByteString::new(vec!())), response_type: Cell::new(_empty), response_xml: Default::default(), - response_headers: RefCell::new(ResponseHeaderCollection::new()), + response_headers: DOMRefCell::new(ResponseHeaderCollection::new()), - request_method: RefCell::new(Get), - request_url: RefCell::new(None), - request_headers: RefCell::new(RequestHeaderCollection::new()), + request_method: DOMRefCell::new(Get), + request_url: DOMRefCell::new(None), + request_headers: DOMRefCell::new(RequestHeaderCollection::new()), request_body_len: Cell::new(0), sync: Cell::new(false), send_flag: Cell::new(false), @@ -163,10 +164,10 @@ impl XMLHttpRequest { global: GlobalField::from_rooted(global), pinned_count: Cell::new(0), - timer: RefCell::new(Timer::new().unwrap()), + timer: DOMRefCell::new(Timer::new().unwrap()), fetch_time: Cell::new(0), timeout_pinned: Cell::new(false), - terminate_sender: RefCell::new(None), + terminate_sender: DOMRefCell::new(None), } } pub fn new(global: &GlobalRef) -> Temporary {