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

@ -17,6 +17,9 @@ path = "../../../components/net_traits"
[dependencies.util]
path = "../../../components/util"
[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"
[dependencies]
cookie = "0.1"
hyper = "0.6"

View file

@ -4,6 +4,7 @@
extern crate hyper;
use ipc_channel::ipc;
use net_traits::LoadConsumer::Channel;
use net_traits::LoadData;
use net_traits::ProgressMsg::{Payload, Done};
@ -19,7 +20,7 @@ fn assert_parse(url: &'static str,
use url::Url;
use net::data_loader::load;
let (start_chan, start_port) = channel();
let (start_chan, start_port) = ipc::channel().unwrap();
load(LoadData::new(Url::parse(url).unwrap(), None), Channel(start_chan));
let response = start_port.recv().unwrap();

View file

@ -4,6 +4,7 @@
#![cfg_attr(test, feature(box_raw))]
extern crate ipc_channel;
extern crate net;
extern crate net_traits;
extern crate url;

View file

@ -2,9 +2,8 @@
* 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 net::resource_task::new_resource_task;
use net::resource_task::parse_hostsfile;
use net::resource_task::replace_hosts;
use ipc_channel::ipc;
use net::resource_task::{new_resource_task, parse_hostsfile, replace_hosts};
use net_traits::{ControlMsg, LoadData, LoadConsumer};
use net_traits::ProgressMsg;
use std::borrow::ToOwned;
@ -21,7 +20,7 @@ fn test_exit() {
#[test]
fn test_bad_scheme() {
let resource_task = new_resource_task(None, None);
let (start_chan, start) = channel();
let (start_chan, start) = ipc::channel().unwrap();
let url = Url::parse("bogus://whatever").unwrap();
resource_task.send(ControlMsg::Load(LoadData::new(url, None), LoadConsumer::Channel(start_chan))).unwrap();
let response = start.recv().unwrap();
@ -170,7 +169,7 @@ fn test_replace_hosts() {
//Start the resource task and make a request to our TCP server
let resource_task = new_resource_task(None, None);
let (start_chan, _) = channel();
let (start_chan, _start_port) = ipc::channel().unwrap();
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
let msg = ControlMsg::Load(replace_hosts(LoadData::new(url, None), host_table),
LoadConsumer::Channel(start_chan));