script: Make the resource task communication use IPC channels.

This commit is contained in:
Patrick Walton 2015-07-09 17:16:21 -07:00
parent 44d13f7fd4
commit 2aa5174246
35 changed files with 234 additions and 458 deletions

View file

@ -74,7 +74,7 @@ use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyMod
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
use net_traits::CookieSource::NonHTTP;
use net_traits::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
use net_traits::{Metadata, PendingAsyncLoad, AsyncResponseTarget, SerializableUrl};
use net_traits::{Metadata, PendingAsyncLoad, AsyncResponseTarget};
use script_task::Runnable;
use script_traits::{MouseButton, UntrustedNodeAddress};
use util::opts;
@ -83,6 +83,7 @@ use layout_interface::{ReflowGoal, ReflowQueryType};
use euclid::point::Point2D;
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
use ipc_channel::ipc;
use layout_interface::{LayoutChan, Msg};
use string_cache::{Atom, QualName};
use url::Url;
@ -1720,10 +1721,8 @@ impl<'a> DocumentMethods for &'a Document {
return Err(Security);
}
let window = self.window.root();
let (tx, rx) = channel();
let _ = window.r().resource_task().send(GetCookiesForUrl(SerializableUrl(url),
tx,
NonHTTP));
let (tx, rx) = ipc::channel().unwrap();
let _ = window.r().resource_task().send(GetCookiesForUrl(url, tx, NonHTTP));
let cookies = rx.recv().unwrap();
Ok(cookies.unwrap_or("".to_owned()))
}
@ -1736,9 +1735,7 @@ impl<'a> DocumentMethods for &'a Document {
return Err(Security);
}
let window = self.window.root();
let _ = window.r().resource_task().send(SetCookiesForUrl(SerializableUrl(url),
cookie,
NonHTTP));
let _ = window.r().resource_task().send(SetCookiesForUrl(url, cookie, NonHTTP));
Ok(())
}