diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2015-10-15 16:52:09 -0700 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2015-10-15 16:53:47 -0700 |
commit | 827f2b873ce7d57fdfe33ce1e55e46835620e8f8 (patch) | |
tree | 49501ee5ef78cf199ed64c200d2d89cb0bf02ef9 /components/script/cors.rs | |
parent | c1aff0b678d346e5f782e06a3e1e512128fa3f05 (diff) | |
download | servo-827f2b873ce7d57fdfe33ce1e55e46835620e8f8.tar.gz servo-827f2b873ce7d57fdfe33ce1e55e46835620e8f8.zip |
Simplify AsyncResponseListener implementations.
Diffstat (limited to 'components/script/cors.rs')
-rw-r--r-- | components/script/cors.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/components/script/cors.rs b/components/script/cors.rs index 31f5f2f9a22..f23925b29ed 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -23,7 +23,6 @@ use network_listener::{NetworkListener, PreInvoke}; use script_task::ScriptChan; use std::ascii::AsciiExt; use std::borrow::ToOwned; -use std::cell::RefCell; use std::sync::{Arc, Mutex}; use time::{self, Timespec, now}; use unicase::UniCase; @@ -106,7 +105,7 @@ impl CORSRequest { script_chan: Box<ScriptChan + Send>) { struct CORSContext { listener: Box<AsyncCORSResponseListener + Send>, - response: RefCell<Option<CORSResponse>>, + response: Option<CORSResponse>, } // This is shoe-horning the CORSReponse stuff into the rest of the async network @@ -119,7 +118,7 @@ impl CORSRequest { } fn response_complete(&mut self, _status: Result<(), String>) { - let response = self.response.borrow_mut().take().unwrap(); + let response = self.response.take().unwrap(); self.listener.response_available(response); } } @@ -127,7 +126,7 @@ impl CORSRequest { let context = CORSContext { listener: listener, - response: RefCell::new(None), + response: None, }; let listener = NetworkListener { context: Arc::new(Mutex::new(context)), @@ -141,7 +140,7 @@ impl CORSRequest { let response = req.http_fetch(); let mut context = listener.context.lock(); let context = context.as_mut().unwrap(); - *context.response.borrow_mut() = Some(response); + context.response = Some(response); listener.notify(ResponseAction::ResponseComplete(Ok(()))); }); } |