diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-07-09 16:50:06 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-07-31 11:27:49 -0700 |
commit | 44d13f7fd419bdff1420ed21ca3efd72f4015bfa (patch) | |
tree | eef95c16a10775746262be4eb8fae0859b7ae15d /components/script/cors.rs | |
parent | 9c9d7dc93b1d64b1524eb2bdcbdc817319abc8b9 (diff) | |
download | servo-44d13f7fd419bdff1420ed21ca3efd72f4015bfa.tar.gz servo-44d13f7fd419bdff1420ed21ca3efd72f4015bfa.zip |
net: Use a thread for each `AsyncResponseTarget` to avoid having to send
trait objects across process boundaries.
Diffstat (limited to 'components/script/cors.rs')
-rw-r--r-- | components/script/cors.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/components/script/cors.rs b/components/script/cors.rs index 1e274a5b9fd..e2ecb1da5cb 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -17,6 +17,7 @@ use net_traits::{SerializableStringResult}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::RefCell; +use std::sync::mpsc; use std::sync::{Arc, Mutex}; use time; use time::{now, Timespec}; @@ -132,9 +133,14 @@ impl CORSRequest { listener: listener, response: RefCell::new(None), }; + let (action_sender, action_receiver) = mpsc::channel(); let listener = NetworkListener { context: Arc::new(Mutex::new(context)), script_chan: script_chan, + receiver: action_receiver, + }; + let response_target = AsyncResponseTarget { + sender: action_sender, }; // TODO: this exists only to make preflight check non-blocking @@ -145,7 +151,7 @@ impl CORSRequest { let mut context = listener.context.lock(); let context = context.as_mut().unwrap(); *context.response.borrow_mut() = Some(response); - listener.invoke_with_listener(ResponseAction::ResponseComplete( + response_target.invoke_with_listener(ResponseAction::ResponseComplete( SerializableStringResult(Ok(())))); }); } |